[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 03/15: [libgroff]: Continue font boolification.
From: |
G. Branden Robinson |
Subject: |
[groff] 03/15: [libgroff]: Continue font boolification. |
Date: |
Fri, 17 Sep 2021 05:34:36 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 73360a55c4f99369fccdcd8627f924a74c023553
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Sep 17 07:38:31 2021 +1000
[libgroff]: Continue font boolification.
* src/include/font.h (font::unit_scale):
* src/libs/libgroff/font.cpp (font::unit_scale): Demote return type from
`int` to `bool`. Use Boolean literals instead of integers.
---
ChangeLog | 5 +++++
src/include/font.h | 12 ++++++------
src/libs/libgroff/font.cpp | 10 ++++++----
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 789e0e3..d5ff675 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
[libgroff]: Boolify more interfaces.
+ * src/include/font.h (font::unit_scale):
+ * src/libs/libgroff/font.cpp (font::unit_scale): Demote return
+ type from `int` to `bool`. Use Boolean literals instead of
+ integers.
+
* src/libs/libgroff/font.cpp (struct text_file): Rename `next`
member function to `next_line`. Demote its return type from
`int` to `bool`. Use Boolean literals instead of integers.
diff --git a/src/include/font.h b/src/include/font.h
index 1eb3460..62fb319 100644
--- a/src/include/font.h
+++ b/src/include/font.h
@@ -316,12 +316,12 @@ private:
/* Returns w * pointsize / unitwidth, rounded to the nearest integer. */
int scale(int w, int pointsize);
- static int unit_scale(double *, char); // Convert value in arg1 from the
- // given unit (arg2; possible values are 'i', 'c',
- // 'p', and 'P' as documented in the info file of
- // groff, section 'Measurements') to inches. Store
- // the result in arg1 and return 1. If the unit is
- // invalid, return 0.
+ static bool unit_scale(double *, char); // Convert value in arg1 from
+ // the given unit (arg2; possible values are
+ // 'i', 'c', 'p', and 'P' as documented in the
+ // info file of groff, section 'Measurements')
+ // to inches. Store result in arg1 and return
+ // whether conversion was successful.
virtual void handle_unknown_font_command(const char *, // command
const char *, // arg
const char *, // file
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 553bc12..9b4cbd2 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -265,9 +265,11 @@ inline int font::scale(int w, int sz)
return sz == unitwidth ? w : scale_round(w, sz, unitwidth);
}
-int font::unit_scale(double *value, char unit)
+// Returns whether scaling by arguments was successful. Used for paper
+// size conversions.
+bool font::unit_scale(double *value, char unit)
{
- // we scale everything to inch
+ // Paper sizes are handled in inches.
double divisor = 0;
switch (unit) {
case 'i':
@@ -288,9 +290,9 @@ int font::unit_scale(double *value, char unit)
}
if (divisor) {
*value /= divisor;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
int font::get_skew(glyph *g, int point_size, int sl)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 03/15: [libgroff]: Continue font boolification.,
G. Branden Robinson <=