mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
LibPDF: Accept font size in PDFFont::get_char_width
This will be required for TTF fonts
This commit is contained in:
parent
5f9d35909d
commit
058cf5f7f7
4 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ public:
|
||||||
virtual ~PDFFont() = default;
|
virtual ~PDFFont() = default;
|
||||||
|
|
||||||
virtual u32 char_code_to_code_point(u16 char_code) const = 0;
|
virtual u32 char_code_to_code_point(u16 char_code) const = 0;
|
||||||
virtual float get_char_width(u16 char_code) const = 0;
|
virtual float get_char_width(u16 char_code, float font_size) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ u32 Type1Font::char_code_to_code_point(u16 char_code) const
|
||||||
return descriptor.code_point;
|
return descriptor.code_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Type1Font::get_char_width(u16 char_code) const
|
float Type1Font::get_char_width(u16 char_code, float) const
|
||||||
{
|
{
|
||||||
u16 width;
|
u16 width;
|
||||||
if (auto char_code_width = m_widths.get(char_code); char_code_width.has_value()) {
|
if (auto char_code_width = m_widths.get(char_code); char_code_width.has_value()) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
~Type1Font() override = default;
|
~Type1Font() override = default;
|
||||||
|
|
||||||
u32 char_code_to_code_point(u16 char_code) const override;
|
u32 char_code_to_code_point(u16 char_code) const override;
|
||||||
float get_char_width(u16 char_code) const override;
|
float get_char_width(u16 char_code, float font_size) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<StreamObject> m_to_unicode;
|
RefPtr<StreamObject> m_to_unicode;
|
||||||
|
|
|
@ -654,7 +654,7 @@ void Renderer::show_text(String const& string, float shift)
|
||||||
|
|
||||||
for (auto char_code : string.bytes()) {
|
for (auto char_code : string.bytes()) {
|
||||||
auto code_point = text_state().font->char_code_to_code_point(char_code);
|
auto code_point = text_state().font->char_code_to_code_point(char_code);
|
||||||
auto char_width = text_state().font->get_char_width(char_code);
|
auto char_width = text_state().font->get_char_width(char_code, font_size);
|
||||||
|
|
||||||
if (code_point != 0x20)
|
if (code_point != 0x20)
|
||||||
m_painter.draw_glyph(glyph_position.to_type<int>(), code_point, *font, state().paint_color);
|
m_painter.draw_glyph(glyph_position.to_type<int>(), code_point, *font, state().paint_color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue