gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
embolden.c
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2
/*
3
* Copyright (C) 2026 Cyril Hrubis <metan@ucw.cz>
4
*/
5
6
#include <stdlib.h>
7
8
#include "
embolden.h
"
9
10
int
gpf_embolden(
struct
gpf_glyph
*self,
int
cell_width)
11
{
12
unsigned
int
w, x, y;
13
uint8_t *bits;
14
15
if
(!self->
width
|| !self->
height
)
16
return
0;
17
18
w = self->
width
+ 1;
19
20
/* the smear would leave the cell, so it is the smear that gives way */
21
if
(cell_width && self->
bearing_x
+ (
int
)w > cell_width)
22
w = self->
width
;
23
24
bits = calloc(1, (
size_t
)w * self->
height
);
25
if
(!bits)
26
return
1;
27
28
for
(y = 0; y < self->
height
; y++) {
29
for
(x = 0; x < self->
width
; x++) {
30
if
(!self->
bits
[y * self->
width
+ x])
31
continue
;
32
33
bits[y * w + x] = 1;
34
35
if
(x + 1 < w)
36
bits[y * w + x + 1] = 1;
37
}
38
}
39
40
free(self->
bits
);
41
42
self->
bits
= bits;
43
self->
width
= w;
44
45
return
0;
46
}
embolden.h
Generates bold letters.
gpf_glyph
A glyph.
Definition
font.h:80
gpf_glyph::bits
uint8_t * bits
Glyph ink.
Definition
font.h:145
gpf_glyph::height
unsigned int height
Glyph ink height.
Definition
font.h:137
gpf_glyph::width
unsigned int width
Glyph ink width.
Definition
font.h:133
gpf_glyph::bearing_x
int bearing_x
Glyph bearing x.
Definition
font.h:122
embolden.c
Generated by
1.15.0