diff --git a/defaults.lua b/defaults.lua index 792e0cd25..4a0ffd962 100644 --- a/defaults.lua +++ b/defaults.lua @@ -97,6 +97,9 @@ DGESDETECT_DISABLE_DOUBLE_TAP = true -- change this to any numerical value if you want to antomatically save settings when turning pages DAUTO_SAVE_PAGING_COUNT = nil +-- dictionary font size +DDICT_FONT_SIZE = 20 + -- #################################################################### -- following features are not supported right now -- #################################################################### diff --git a/frontend/ui/rendertext.lua b/frontend/ui/rendertext.lua index 36deba8b8..94c058f9c 100644 --- a/frontend/ui/rendertext.lua +++ b/frontend/ui/rendertext.lua @@ -143,7 +143,7 @@ function RenderText:sizeUtf8Text(x, width, face, text, kerning) return { x = pen_x, y_top = pen_y_top, y_bottom = pen_y_bottom} end -function RenderText:renderUtf8Text(buffer, x, y, face, text, kerning, bgcolor, fgcolor) +function RenderText:renderUtf8Text(buffer, x, y, face, text, kerning, bgcolor, fgcolor, width) if not text then DEBUG("renderUtf8Text called without text"); return 0 @@ -153,9 +153,12 @@ function RenderText:renderUtf8Text(buffer, x, y, face, text, kerning, bgcolor, f -- see: http://freetype.org/freetype2/docs/glyphs/glyphs-4.html local pen_x = 0 local prevcharcode = 0 - local buffer_width = buffer:getWidth() + local text_width = buffer:getWidth() - x + if width and width < text_width then + text_width = width + end for _, charcode, uchar in utf8Chars(text) do - if pen_x < buffer_width then + if pen_x < text_width then local glyph = self:getGlyph(face, charcode, bgcolor, fgcolor) if kerning and (prevcharcode ~= 0) then pen_x = pen_x + face.ftface:getKerning(prevcharcode, charcode) @@ -167,7 +170,7 @@ function RenderText:renderUtf8Text(buffer, x, y, face, text, kerning, bgcolor, f glyph.bb:getWidth(), glyph.bb:getHeight(), 1) pen_x = pen_x + glyph.ax prevcharcode = charcode - end -- if pen_x < buffer_width + end -- if pen_x < text_width end return pen_x diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 92c219638..cd0c87dbb 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -31,7 +31,7 @@ local DictQuickLookup = InputContainer:new{ dict_index = 1, title_face = Font:getFace("tfont", 22), word_face = Font:getFace("tfont", 22), - content_face = Font:getFace("cfont", 20), + content_face = Font:getFace("cfont", DDICT_FONT_SIZE), width = nil, height = nil, @@ -85,7 +85,7 @@ function DictQuickLookup:update() TextWidget:new{ text = self.dictionary, face = self.title_face, - width = self.width, + width = self.width - self.button_padding, } } -- lookup word diff --git a/frontend/ui/widget/textwidget.lua b/frontend/ui/widget/textwidget.lua index 0c87f9937..fa9c0a958 100644 --- a/frontend/ui/widget/textwidget.lua +++ b/frontend/ui/widget/textwidget.lua @@ -47,7 +47,7 @@ function TextWidget:paintTo(bb, x, y) --bb:blitFrom(self._bb, x, y, 0, 0, self._length, self._bb:getHeight()) --@TODO Don't use kerning for monospaced fonts. (houqp) RenderText:renderUtf8Text(bb, x, y+self._height*0.7, self.face, self.text, - true, self.bgcolor, self.fgcolor) + true, self.bgcolor, self.fgcolor, self.width) end function TextWidget:free()