MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / interpretFontWeight

Method interpretFontWeight

lib/Epub/Epub/css/CssParser.cpp:237–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237CssFontWeight CssParser::interpretFontWeight(std::string_view val) {
238 val = trimCssWhitespace(val);
239
240 // Named values
241 if (iequalsAscii(val, "bold") || iequalsAscii(val, "bolder")) return CssFontWeight::Bold;
242 if (iequalsAscii(val, "normal") || iequalsAscii(val, "lighter")) return CssFontWeight::Normal;
243
244 // Numeric values: 100-900
245 // CSS spec: 400 = normal, 700 = bold
246 // We use: 0-400 = normal, 700+ = bold, 500-600 = normal (conservative)
247 long numericWeight = 0;
248 if (tryParseNumber(val, numericWeight)) {
249 return numericWeight >= 700 ? CssFontWeight::Bold : CssFontWeight::Normal;
250 }
251 return CssFontWeight::Normal;
252}
253
254CssTextDecoration CssParser::interpretDecoration(std::string_view val) {
255 // text-decoration can have multiple space-separated values

Callers

nothing calls this directly

Calls 3

trimCssWhitespaceFunction · 0.85
iequalsAsciiFunction · 0.85
tryParseNumberFunction · 0.85

Tested by

no test coverage detected