mirror of
https://github.com/simon987/sist2.git
synced 2025-04-16 08:56:45 +00:00
Font rendering fixes
This commit is contained in:
parent
f8b081a3f4
commit
784c3c9435
@ -56,7 +56,7 @@ sist2 web --bind 0.0.0.0 --port 4321 ./my_idx1 ./my_idx2 ./my_idx3
|
||||
|
||||
File type | Library | Content | Thumbnail | Metadata
|
||||
:---|:---|:---|:---|:---
|
||||
pdf,xps,cbz,cbr,fb2,epub | MuPDF | yes | yes, `png` | *planned* |
|
||||
pdf,xps,cbz,cbr,fb2,epub | MuPDF | yes | yes, `png` | title |
|
||||
`audio/*` | libav | - | yes, `jpeg` | ID3 tags |
|
||||
`video/*` | libav | - | yes, `jpeg` | *planned* |
|
||||
`image/*` | libav | - | yes, `jpeg` | *planned* |
|
||||
@ -85,7 +85,7 @@ binaries.
|
||||
```bash
|
||||
pkg install cmake gcc yasm gmake bash ffmpeg e2fsprogs-uuid
|
||||
```
|
||||
__
|
||||
|
||||
2. Build
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/simon987/sist2
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||
|
||||
|
||||
static const char *const Version = "1.0.12";
|
||||
static const char *const Version = "1.0.13";
|
||||
static const char *const usage[] = {
|
||||
"sist2 scan [OPTION]... PATH",
|
||||
"sist2 index [OPTION]... INDEX",
|
||||
|
@ -15,12 +15,12 @@ typedef struct text_dimensions {
|
||||
} text_dimensions_t;
|
||||
|
||||
typedef struct glyph {
|
||||
unsigned int top;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
unsigned int descent;
|
||||
unsigned int ascent;
|
||||
unsigned int advance_width;
|
||||
int top;
|
||||
int height;
|
||||
int width;
|
||||
int descent;
|
||||
int ascent;
|
||||
int advance_width;
|
||||
unsigned char *pixmap;
|
||||
} glyph_t;
|
||||
|
||||
@ -39,10 +39,10 @@ glyph_t ft_glyph_to_glyph(FT_GlyphSlot slot) {
|
||||
|
||||
glyph.pixmap = slot->bitmap.buffer;
|
||||
|
||||
glyph.width = slot->bitmap.width;
|
||||
glyph.height = slot->bitmap.rows;
|
||||
glyph.width = (int) slot->bitmap.width;
|
||||
glyph.height = (int) slot->bitmap.rows;
|
||||
glyph.top = slot->bitmap_top;
|
||||
glyph.advance_width = slot->advance.x / 64;
|
||||
glyph.advance_width = (int) slot->advance.x / 64;
|
||||
|
||||
glyph.descent = MAX(0, glyph.height - glyph.top);
|
||||
glyph.ascent = MAX(0, MAX(glyph.top, glyph.height) - glyph.descent);
|
||||
@ -50,10 +50,6 @@ glyph_t ft_glyph_to_glyph(FT_GlyphSlot slot) {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
__always_inline
|
||||
glyph_t get_glyph(char character, FT_Face face) {
|
||||
}
|
||||
|
||||
text_dimensions_t text_dimension(char *text, FT_Face face) {
|
||||
text_dimensions_t dimensions;
|
||||
|
||||
@ -62,7 +58,7 @@ text_dimensions_t text_dimension(char *text, FT_Face face) {
|
||||
int num_chars = (int) strlen(text);
|
||||
|
||||
unsigned int max_ascent = 0;
|
||||
unsigned int max_descent = 0;
|
||||
int max_descent = 0;
|
||||
|
||||
char pc = 0;
|
||||
for (int i = 0; i < num_chars; i++) {
|
||||
@ -72,7 +68,7 @@ text_dimensions_t text_dimension(char *text, FT_Face face) {
|
||||
glyph_t glyph = ft_glyph_to_glyph(face->glyph);
|
||||
|
||||
max_descent = MAX(max_descent, glyph.descent);
|
||||
max_ascent = MAX(max_ascent, glyph.ascent);
|
||||
max_ascent = MAX(max_ascent, MAX(glyph.height, glyph.ascent));
|
||||
|
||||
int kerning_x = kerning_offset(c, pc, face);
|
||||
dimensions.width += MAX(glyph.advance_width, glyph.width) + kerning_x;
|
||||
@ -195,6 +191,9 @@ void parse_font(const char *buf, size_t buf_len, document_t *doc) {
|
||||
glyph_t glyph = ft_glyph_to_glyph(face->glyph);
|
||||
|
||||
pen.x += kerning_offset(c, pc, face);
|
||||
if (pen.x <= 0) {
|
||||
pen.x = ABS(glyph.advance_width - glyph.width);
|
||||
}
|
||||
pen.y = dimensions.height - glyph.ascent - dimensions.baseline;
|
||||
|
||||
draw_glyph(&glyph, pen.x, pen.y, dimensions, bitmap);
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user