mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 03:32:24 +00:00
fontaliases: revise fonts.alias for UTF-8 to display
multi-language correctly.
This commit is contained in:
parent
49c73d57ec
commit
658e42d317
4 changed files with 1372 additions and 2700 deletions
|
@ -3,3 +3,11 @@ MAINTAINERCLEANFILES = Makefile.in
|
||||||
include ../../../localized/templates/English.am
|
include ../../../localized/templates/English.am
|
||||||
include ../../bdf/fonts.am
|
include ../../bdf/fonts.am
|
||||||
|
|
||||||
|
noinst_PROGRAMS = mk_fonts_alias test_fonts_alias
|
||||||
|
|
||||||
|
mk_fonts_alias_SOURCES = mk_fonts_alias.c
|
||||||
|
test_fonts_alias_SOURCES = test_fonts_alias.c
|
||||||
|
test_fonts_alias_LDADD = $(XTOOLLIB)
|
||||||
|
|
||||||
|
fonts.alias: mk_fonts_alias
|
||||||
|
./$< > $@
|
||||||
|
|
File diff suppressed because it is too large
Load diff
1252
cde/programs/fontaliases/linux/en_US.UTF-8/mk_fonts_alias.c
Normal file
1252
cde/programs/fontaliases/linux/en_US.UTF-8/mk_fonts_alias.c
Normal file
File diff suppressed because it is too large
Load diff
112
cde/programs/fontaliases/linux/en_US.UTF-8/test_fonts_alias.c
Normal file
112
cde/programs/fontaliases/linux/en_US.UTF-8/test_fonts_alias.c
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* CDE - Common Desktop Environment
|
||||||
|
*
|
||||||
|
* (c) Copyright 1993-2012 The Open Group
|
||||||
|
* (c) Copyright 2012-2022 CDE Project contributors, see
|
||||||
|
* CONTRIBUTORS for details
|
||||||
|
*
|
||||||
|
* These libraries and programs are free software; you can
|
||||||
|
* redistribute them and/or modify them under the terms of the GNU
|
||||||
|
* Lesser General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* These libraries and programs are distributed in the hope that
|
||||||
|
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU Lesser General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with these libraries and programs; if not, write
|
||||||
|
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||||
|
* Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#define BUF_SIZE 1024
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int ret = 0;
|
||||||
|
int line_num = 0;
|
||||||
|
int npaths;
|
||||||
|
char cwd[BUF_SIZE];
|
||||||
|
char *font_path_list[BUF_SIZE];
|
||||||
|
char **font_path_list_orig = NULL;
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
ssize_t line_len;
|
||||||
|
|
||||||
|
if (!getcwd(cwd, BUF_SIZE)) {
|
||||||
|
fprintf(stderr, "Cannot get current working directory.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
font_path_list[0] = cwd;
|
||||||
|
|
||||||
|
Display *display = XOpenDisplay(NULL);
|
||||||
|
|
||||||
|
if (display == NULL) {
|
||||||
|
fprintf(stderr, "Cannot open display.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
font_path_list_orig = XGetFontPath(display, &npaths);
|
||||||
|
|
||||||
|
for (int i = 0; i < npaths; ++i)
|
||||||
|
font_path_list[i + 1] = font_path_list_orig[i];
|
||||||
|
|
||||||
|
XSetFontPath(display, font_path_list, ++npaths);
|
||||||
|
|
||||||
|
while ((line_len = getline(&line, &len, stdin)) != -1) {
|
||||||
|
int i;
|
||||||
|
char *font_name = NULL;
|
||||||
|
size_t font_name_len = 0;
|
||||||
|
|
||||||
|
++line_num;
|
||||||
|
|
||||||
|
for (i = 0; i < line_len; ++i) {
|
||||||
|
++font_name_len;
|
||||||
|
|
||||||
|
if (!font_name && line[i] == '"') {
|
||||||
|
font_name = &line[i];
|
||||||
|
font_name_len = 0;
|
||||||
|
}
|
||||||
|
else if (font_name && line[i] == '"') break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= line_len || line_len < 3) {
|
||||||
|
fprintf(stderr, "Corrupted file.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(++font_name + --font_name_len) = '\0';
|
||||||
|
|
||||||
|
XFontStruct *font_struct = XLoadQueryFont(display, font_name);
|
||||||
|
|
||||||
|
if (!font_struct) {
|
||||||
|
fprintf(stderr, "Bad alias: %d: %s\n", line_num, font_name);
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (font_struct) XFreeFont(display, font_struct);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (font_path_list_orig) {
|
||||||
|
XSetFontPath(display, font_path_list_orig, --npaths);
|
||||||
|
XFreeFontPath(font_path_list_orig);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line) free(line);
|
||||||
|
if (display) XCloseDisplay(display);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in a new issue