Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
yad
Commits
fe5dfd2e
Commit
fe5dfd2e
authored
Feb 23, 2019
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pfd utility
parent
16f28e71
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
266 additions
and
0 deletions
+266
-0
.gitignore
.gitignore
+1
-0
configure.ac
configure.ac
+13
-0
Makefile.am
data/Makefile.am
+3
-0
pfd.1
data/pfd.1
+21
-0
POTFILES.in
po/POTFILES.in
+1
-0
ru.po
po/ru.po
+0
-0
uk.po
po/uk.po
+0
-0
Makefile.am
src/Makefile.am
+8
-0
pfd.c
src/pfd.c
+219
-0
No files found.
.gitignore
View file @
fe5dfd2e
...
...
@@ -23,4 +23,5 @@ po/*.gmo
po/stamp-it
src/yad
src/yad-icon-browser
src/pfd
stamp-h1
configure.ac
View file @
fe5dfd2e
...
...
@@ -126,6 +126,18 @@ if test x$have_sourceview = xyes; then
AC_DEFINE([HAVE_SOURCEVIEW], [1], [Define this if you need GtkSourceView support])
fi
dnl pfd
AC_ARG_ENABLE([pfd],
[AS_HELP_STRING([--enable-pfd],
[Build pfd utility])],
[build_pfd=$enableval], [build_pfd=yes])
if test x$build_pfd = xyes; then
PKG_CHECK_MODULES([PFD], [pango], [build_pfd=yes], [build_pfd=no])
fi
AC_SUBST([PFD_CFLAGS])
AC_SUBST([PFD_LIBS])
AM_CONDITIONAL([BUILD_PFD], [test x$build_pfd = xyes])
dnl icon browser
AC_ARG_ENABLE([icon-browser],
[AS_HELP_STRING([--enable-icon-browser],
...
...
@@ -177,5 +189,6 @@ echo " HTML widget - $have_html"
echo " Spell checking - $have_spell"
echo " GtkSourceView - $have_sourceview"
echo " GIO support - $have_gio"
echo " pfd - $build_pfd"
echo " Icon browser - $build_ib"
echo
data/Makefile.am
View file @
fe5dfd2e
...
...
@@ -8,6 +8,9 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
endif
dist_man_MANS
=
yad.1
if
BUILD_PFD
dist_man_MANS
+=
pfd.1
endif
m4dir
=
$(datadir)
/aclocal
m4_DATA
=
yad.m4
...
...
data/pfd.1
0 → 100644
View file @
fe5dfd2e
.TH PFD "1" "February 2019" "pfd" "User Commands"
.SH NAME
pfd \- convert font description between xft and pango formats
.SH SYNOPSIS
.B pfd
.RI [ OPTIONS ] FONT
.SH DESCRIPTION
\fBpfd\fR is a small command-line utility to transform font names from pango to xft specification and vice versa.
.SH OPTIONS
.TP
\fB\-x\fR, \fB\-\-xft\fR
Print font name in xft format. This is default.
.TP
\fB\-p\fR, \fB\-\-pango\fR
Print font name in pango format.
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help.
.TP
\fB\-v\fR, \fB\-\-version\fR
Print current version.
po/POTFILES.in
View file @
fe5dfd2e
...
...
@@ -20,4 +20,5 @@ src/color.c
src/text.c
src/browser.c
src/notebook.c
src/pfd.c
data/yad-icon-browser.desktop.in
po/ru.po
View file @
fe5dfd2e
This diff is collapsed.
Click to expand it.
po/uk.po
View file @
fe5dfd2e
This diff is collapsed.
Click to expand it.
src/Makefile.am
View file @
fe5dfd2e
...
...
@@ -37,6 +37,14 @@ endif
yad_CFLAGS
=
$(GTK_CFLAGS)
$(HTML_CFLAGS)
$(SPELL_CFLAGS)
$(SOURCEVIEW_CFLAGS)
yad_LDADD
=
$(GTK_LIBS)
$(HTML_LIBS)
$(SPELL_LIBS)
$(SOURCEVIEW_LIBS)
if
BUILD_PFD
bin_PROGRAMS
+=
pfd
pfd_SOURCES
=
pfd.c
pfd_CFLAGS
=
$(PFD_CFLAGS)
pfd_LDADD
=
$(PFD_LIBS)
endif
if
BUILD_IB
bin_PROGRAMS
+=
yad-icon-browser
...
...
src/pfd.c
0 → 100644
View file @
fe5dfd2e
/*
* This file is part of YAD.
*
* YAD is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* YAD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with YAD. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2019, Victor Ananjevsky <ananasik@gmail.com>
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <pango/pango.h>
typedef
enum
{
PANGO_SPEC
,
XFT_SPEC
}
FontType
;
static
FontType
font_type
=
XFT_SPEC
;
static
gboolean
set_type
(
const
gchar
*
name
,
const
gchar
*
val
,
gpointer
d
,
GError
**
err
)
{
gint
i
=
1
;
if
(
name
[
i
]
==
'-'
)
i
=
2
;
if
(
name
[
i
]
==
'p'
)
font_type
=
PANGO_SPEC
;
else
if
(
name
[
i
]
==
'x'
)
font_type
=
XFT_SPEC
;
else
return
FALSE
;
return
TRUE
;
}
static
gchar
*
parse_font
(
gchar
*
fn
)
{
gchar
**
fnt
;
gint
i
=
1
;
GString
*
pfd
=
g_string_new
(
NULL
);
fnt
=
g_strsplit
(
fn
,
":"
,
-
1
);
if
(
g_ascii_strcasecmp
(
fnt
[
0
],
"xft"
)
!=
0
)
return
fnt
[
0
];
while
(
fnt
[
i
])
{
if
(
g_ascii_strncasecmp
(
fnt
[
i
],
"style="
,
6
)
==
0
)
g_string_append_printf
(
pfd
,
"%s "
,
fnt
[
i
]
+
6
);
else
if
(
g_ascii_strncasecmp
(
fnt
[
i
],
"size="
,
5
)
==
0
)
g_string_append_printf
(
pfd
,
"%s "
,
fnt
[
i
]
+
5
);
else
if
(
g_ascii_strncasecmp
(
fnt
[
i
],
"pixelsize="
,
10
)
==
0
)
g_string_append_printf
(
pfd
,
"%spx "
,
fnt
[
i
]
+
10
);
else
g_string_append_printf
(
pfd
,
"%s "
,
fnt
[
i
]);
i
++
;
}
return
pfd
->
str
;
}
static
gchar
**
fonts
=
NULL
;
static
gboolean
ver
=
FALSE
;
static
GOptionEntry
ents
[]
=
{
{
"xft"
,
'x'
,
G_OPTION_FLAG_NO_ARG
,
G_OPTION_ARG_CALLBACK
,
set_type
,
N_
(
"Print font name in xft format"
),
NULL
},
{
"pango"
,
'p'
,
G_OPTION_FLAG_NO_ARG
,
G_OPTION_ARG_CALLBACK
,
set_type
,
N_
(
"Print font name in pango format"
),
NULL
},
{
"version"
,
'v'
,
0
,
G_OPTION_ARG_NONE
,
&
ver
,
N_
(
"Print version"
),
NULL
},
{
G_OPTION_REMAINING
,
0
,
0
,
G_OPTION_ARG_STRING_ARRAY
,
&
fonts
,
0
,
N_
(
"FONT"
)
},
{
NULL
}
};
int
main
(
int
argc
,
char
*
argv
[])
{
GOptionContext
*
ctx
;
GError
*
err
=
NULL
;
PangoFontDescription
*
fnd
=
NULL
;
setlocale
(
LC_ALL
,
""
);
#ifdef ENABLE_NLS
bindtextdomain
(
GETTEXT_PACKAGE
,
LOCALEDIR
);
bind_textdomain_codeset
(
GETTEXT_PACKAGE
,
"UTF-8"
);
textdomain
(
GETTEXT_PACKAGE
);
#endif
ctx
=
g_option_context_new
(
_
(
"- convert font description"
));
g_option_context_add_main_entries
(
ctx
,
ents
,
GETTEXT_PACKAGE
);
if
(
!
g_option_context_parse
(
ctx
,
&
argc
,
&
argv
,
&
err
))
{
g_printerr
(
_
(
"option parsing failed: %s
\n
"
),
err
->
message
);
return
1
;
}
if
(
ver
)
{
g_print
(
"%s
\n
"
,
VERSION
);
return
0
;
}
if
(
!
fonts
||
!
fonts
[
0
])
{
g_printerr
(
_
(
"no font specified
\n
"
));
return
1
;
}
/* parse font */
fnd
=
pango_font_description_from_string
(
parse_font
(
fonts
[
0
]));
if
(
!
fnd
)
{
g_printerr
(
_
(
"cannot get font description for for string
\"
%s
\"\n
"
),
fonts
[
0
]);
return
1
;
}
/* print font */
switch
(
font_type
)
{
case
PANGO_SPEC
:
g_print
(
"%s
\n
"
,
pango_font_description_to_string
(
fnd
));
break
;
case
XFT_SPEC
:
{
PangoFontMask
mask
=
pango_font_description_get_set_fields
(
fnd
);
if
(
mask
&
PANGO_FONT_MASK_FAMILY
)
g_print
(
"xft:%s"
,
pango_font_description_get_family
(
fnd
));
else
g_print
(
"xft:Sans"
);
/* simple default */
if
(
mask
&
PANGO_FONT_MASK_WEIGHT
)
{
switch
(
pango_font_description_get_weight
(
fnd
))
{
case
PANGO_WEIGHT_THIN
:
g_print
(
":Thin"
);
break
;
case
PANGO_WEIGHT_ULTRALIGHT
:
g_print
(
":Ultralight"
);
break
;
case
PANGO_WEIGHT_LIGHT
:
g_print
(
":Light"
);
break
;
case
PANGO_WEIGHT_SEMILIGHT
:
g_print
(
":Semilight"
);
break
;
case
PANGO_WEIGHT_BOOK
:
g_print
(
":Book"
);
break
;
case
PANGO_WEIGHT_NORMAL
:
break
;
case
PANGO_WEIGHT_MEDIUM
:
g_print
(
":Medium"
);
break
;
case
PANGO_WEIGHT_SEMIBOLD
:
g_print
(
":Semibold"
);
break
;
case
PANGO_WEIGHT_BOLD
:
g_print
(
":Bold"
);
break
;
case
PANGO_WEIGHT_ULTRABOLD
:
g_print
(
":Ultrabold"
);
break
;
case
PANGO_WEIGHT_HEAVY
:
g_print
(
":Heavy"
);
break
;
case
PANGO_WEIGHT_ULTRAHEAVY
:
g_print
(
":Ultraheavy"
);
break
;
}
}
if
(
mask
&
PANGO_FONT_MASK_STYLE
)
{
switch
(
pango_font_description_get_style
(
fnd
))
{
case
PANGO_STYLE_NORMAL
:
break
;
case
PANGO_STYLE_OBLIQUE
:
g_print
(
":Oblique"
);
break
;
case
PANGO_STYLE_ITALIC
:
g_print
(
":Italic"
);
break
;
}
}
if
(
mask
&
PANGO_FONT_MASK_SIZE
)
{
if
(
pango_font_description_get_size_is_absolute
(
fnd
))
g_print
(
":pixelsize=%d"
,
pango_font_description_get_size
(
fnd
)
/
PANGO_SCALE
);
else
g_print
(
":size=%d"
,
pango_font_description_get_size
(
fnd
)
/
PANGO_SCALE
);
}
g_print
(
"
\n
"
);
break
;
}
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment