diff --git a/frontend/ui/data/creoptions.lua b/frontend/ui/data/creoptions.lua index 05ca9720c..6bac8246d 100644 --- a/frontend/ui/data/creoptions.lua +++ b/frontend/ui/data/creoptions.lua @@ -15,6 +15,36 @@ local tableOfNumbersToTableOfStrings = function(numbers) return t end +-- OS/2 weight classes map +-- c.f., https://docs.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass +local usWeightClass = { + [100] = C_("Font weight class", "Thin"), + [200] = C_("Font weight class", "Extra-light"), + [300] = C_("Font weight class", "Light"), + [400] = C_("Font weight class", "Regular"), + [500] = C_("Font weight class", "Medium"), + [600] = C_("Font weight class", "Semi-bold"), + [700] = C_("Font weight class", "Bold"), + [800] = C_("Font weight class", "Extra-bold"), + [900] = C_("Font weight class", "Black"), +} + +local function weightClassToString(weight) + if usWeightClass[weight] then + return T(_("%1 (%2)"), usWeightClass[weight], weight) + else + return tostring(weight) + end +end + +local function prettifyCreWeights(t) + local p = {} + for __, v in ipairs(t) do + table.insert(p, weightClassToString(v)) + end + return p +end + local CreOptions = { prefix = 'copt', { @@ -537,19 +567,19 @@ Note that your selected font size is not affected by this setting.]]), }, help_text = _([[Set the font weight delta from "regular" to apply to all fonts. -- 0 will use the "regular (400)" variation of a font. -- +1 will use the "medium (500)" variation of a font if available. -- +3 will use the "bold (700)" variation of a font if available. +- 0 will use the "Regular (400)" variation of a font. +- +1 will use the "Medium (500)" variation of a font if available. +- +3 will use the "Bold (700)" variation of a font if available. If a font variation is not available, as well as for fractional adjustments, it will be synthesized from the nearest available weight.]]), help_text_func = function(configurable, document) local font_face = document:getFontFace() - local available_weights = cre.getFontFaceAvailableWeights(font_face) - return T(_("The default font '%1' provides the following weight classes: %2."), font_face, table.concat(available_weights, ", ")) + local available_weights = prettifyCreWeights(cre.getFontFaceAvailableWeights(font_face)) + return T(_("The default font '%1' provides the following weight classes: %2."), font_face, table.concat(available_weights, C_("List separator", ", "))) end, name_text_hold_callback = optionsutil.showValues, name_text_true_values = true, show_true_value_func = function(val) - return string.format("%d", 400+val*100) + return weightClassToString(400+val*100) end, }, {