diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 94f1aeb826..21e2ebe5af 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -135,7 +135,7 @@ struct AIConfigWindow : public Window { break; case WID_AIC_LIST: - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; resize->height = this->line_height; size->height = 8 * this->line_height; break; diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index 1e7c8e62c1..cb7eae122a 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -38,7 +38,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r) SetDParam(1, u->build_year); SetDParam(2, u->value); DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); SetDParam(0, u->cargo_type); SetDParam(1, u->cargo_cap); @@ -46,7 +46,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r) SetDParam(3, u->Next()->cargo_cap); SetDParam(4, GetCargoSubtypeText(u)); DrawString(r.left, r.right, y, (u->Next()->cargo_cap != 0) ? STR_VEHICLE_INFO_CAPACITY_CAPACITY : STR_VEHICLE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } if (u->cargo_cap != 0) { @@ -58,7 +58,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r) SetDParam(1, cargo_count); SetDParam(2, u->cargo.GetFirstStation()); DrawString(r.left, r.right, y, STR_VEHICLE_DETAILS_CARGO_FROM); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); feeder_share += u->cargo.GetFeederShare(); } } diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index b7b6284388..a19cfc03db 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -338,7 +338,7 @@ public: size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width); } - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; size->height = 5 * this->line_height; break; } @@ -431,14 +431,14 @@ public: /* show the noise of the selected airport */ SetDParam(0, as->noise_level); DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE); - top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } if (_settings_game.economy.infrastructure_maintenance) { Money monthly = _price[PR_INFRASTRUCTURE_AIRPORT] * as->maintenance_cost >> 3; SetDParam(0, monthly * 12); DrawString(r.left, r.right, top, STR_STATION_BUILD_INFRASTRUCTURE_COST); - top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } /* strings such as 'Size' and 'Coverage Area' */ diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 508a96433d..b6ff9f6674 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -334,7 +334,7 @@ public: case WID_RV_LEFT_DETAILS: case WID_RV_RIGHT_DETAILS: - size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height; + size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; break; case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { @@ -530,7 +530,7 @@ public: const Rect r = this->GetWidget(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect() .Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect); int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine[side], ted); - needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL); + needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL)); } } if (needed_height != this->details_height) { // Details window are not high enough, enlarge them. diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 290a0f2cd0..3b2aa002d4 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -51,7 +51,7 @@ */ uint GetEngineListHeight(VehicleType type) { - return std::max(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical(), GetVehicleImageCellSize(type, EIT_PURCHASE).height); + return std::max(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(), GetVehicleImageCellSize(type, EIT_PURCHASE).height); } static const NWidgetPart _nested_build_vehicle_widgets[] = { @@ -582,7 +582,7 @@ static int DrawCargoCapacityInfo(int left, int right, int y, TestedEngineDetails SetDParam(1, te.all_capacities[cid]); SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY); DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } return y; @@ -602,14 +602,14 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine SetDParam(0, e->GetCost()); DrawString(left, right, y, STR_PURCHASE_INFO_COST); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Wagon weight - (including cargo) */ uint weight = e->GetDisplayWeight(); SetDParam(0, weight); SetDParam(1, GetCargoWeight(te.all_capacities, VEH_TRAIN) + weight); DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Wagon speed limit, displayed if above zero */ if (_settings_game.vehicle.wagon_speed_limits) { @@ -617,7 +617,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine if (max_speed > 0) { SetDParam(0, PackVelocity(max_speed, e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_SPEED); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } } @@ -625,7 +625,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine if (rvi->running_cost_class != INVALID_PRICE) { SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } return y; @@ -647,26 +647,26 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin SetDParam(1, e->GetDisplayWeight()); DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Max speed - Engine power */ SetDParam(0, PackVelocity(e->GetDisplayMaxSpeed(), e->type)); SetDParam(1, e->GetPower()); DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Max tractive effort - not applicable if old acceleration or maglev */ if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(rvi->railtype)->acceleration_type != 2) { SetDParam(0, e->GetDisplayMaxTractiveEffort()); DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } /* Running cost */ if (rvi->running_cost_class != INVALID_PRICE) { SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } /* Powered wagons power - Powered wagons extra weight */ @@ -674,7 +674,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin SetDParam(0, rvi->pow_wag_power); SetDParam(1, rvi->pow_wag_weight); DrawString(left, right, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } return y; @@ -695,25 +695,25 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n SetDParam(0, e->GetCost()); DrawString(left, right, y, STR_PURCHASE_INFO_COST); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Road vehicle weight - (including cargo) */ int16_t weight = e->GetDisplayWeight(); SetDParam(0, weight); SetDParam(1, GetCargoWeight(te.all_capacities, VEH_ROAD) + weight); DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Max speed - Engine power */ SetDParam(0, PackVelocity(e->GetDisplayMaxSpeed(), e->type)); SetDParam(1, e->GetPower()); DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Max tractive effort */ SetDParam(0, e->GetDisplayMaxTractiveEffort()); DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } else { /* Purchase cost - Max speed */ if (te.cost != 0) { @@ -726,13 +726,13 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n SetDParam(1, PackVelocity(e->GetDisplayMaxSpeed(), e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } /* Running cost */ SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); return y; } @@ -758,7 +758,7 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb SetDParam(1, PackVelocity(ocean_speed, e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } else { if (te.cost != 0) { SetDParam(0, e->GetCost() + te.cost); @@ -768,15 +768,15 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb SetDParam(0, e->GetCost()); DrawString(left, right, y, STR_PURCHASE_INFO_COST); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); SetDParam(0, PackVelocity(ocean_speed, e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_OCEAN); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); SetDParam(0, PackVelocity(canal_speed, e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_CANAL); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } /* Cargo type + capacity */ @@ -784,12 +784,12 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb SetDParam(1, te.capacity); SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY); DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Running cost */ SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); return y; } @@ -818,7 +818,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_ SetDParam(1, PackVelocity(e->GetDisplayMaxSpeed(), e->type)); DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Cargo capacity */ if (te.mail_capacity > 0) { @@ -835,24 +835,24 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_ SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY); DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Running cost */ SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Aircraft type */ SetDParam(0, e->GetAircraftTypeText()); DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_TYPE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Aircraft range, if available. */ uint16_t range = e->GetRange(); if (range != 0) { SetDParam(0, range); DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_RANGE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } return y; @@ -958,7 +958,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, SetDParam(0, CT_INVALID); SetDParam(2, STR_EMPTY); DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } else { y = new_y; } @@ -970,12 +970,12 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, SetDParam(0, ymd.year); SetDParam(1, TimerGameCalendar::DateToYear(e->GetLifeLengthInDays())); DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED_LIFE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Reliability */ SetDParam(0, ToPercent16(e->reliability)); DrawString(left, right, y, STR_PURCHASE_INFO_RELIABILITY); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } if (refittable) y = ShowRefitOptionsList(left, right, y, engine_number); @@ -988,7 +988,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, if (_settings_client.gui.show_newgrf_name && config != nullptr) { DrawString(left, right, y, config->GetName(), TC_BLACK); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } return y; @@ -1044,8 +1044,8 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li Rect rr = tr.WithWidth(replace_icon.width, !rtl); // Replace icon position if (show_count) tr = tr.Indent(count_width + WidgetDimensions::scaled.hsep_normal + replace_icon.width + WidgetDimensions::scaled.hsep_wide, !rtl); - int normal_text_y_offset = (ir.Height() - FONT_HEIGHT_NORMAL) / 2; - int small_text_y_offset = ir.Height() - FONT_HEIGHT_SMALL; + int normal_text_y_offset = (ir.Height() - GetCharacterHeight(FS_NORMAL)) / 2; + int small_text_y_offset = ir.Height() - GetCharacterHeight(FS_SMALL); int replace_icon_y_offset = (ir.Height() - replace_icon.height) / 2; int y = ir.top; @@ -1085,7 +1085,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li if (indent > 0) { /* Draw tree lines */ Rect fr = ir.Indent(indent - WidgetDimensions::scaled.hsep_indent, rtl).WithWidth(circle_width, rtl); - int ycenter = y + normal_text_y_offset + FONT_HEIGHT_NORMAL / 2; + int ycenter = y + normal_text_y_offset + GetCharacterHeight(FS_NORMAL) / 2; bool continues = (min + 1U) < eng_list.size() && eng_list[min + 1].indent == item.indent; GfxDrawLine(fr.left + circle_width / 2, y - WidgetDimensions::scaled.matrix.top, fr.left + circle_width / 2, continues ? y - WidgetDimensions::scaled.matrix.top + step_size - 1 : ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top); GfxDrawLine(fr.left + circle_width / 2, ycenter, fr.right, ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top); @@ -1751,7 +1751,7 @@ struct BuildVehicleWindow : Window { break; case WID_BV_PANEL: - size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height; + size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; break; case WID_BV_SORT_ASCENDING_DESCENDING: { @@ -1822,12 +1822,12 @@ struct BuildVehicleWindow : Window { if (this->sel_engine != INVALID_ENGINE) { const Rect r = this->GetWidget(WID_BV_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect); int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine, this->te); - needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL); + needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL)); } if (needed_height != this->details_height) { // Details window are not high enough, enlarge them. int resize = needed_height - this->details_height; this->details_height = needed_height; - this->ReInit(0, resize * FONT_HEIGHT_NORMAL); + this->ReInit(0, resize * GetCharacterHeight(FS_NORMAL)); return; } } diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 57899b9cc0..16ca022c30 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -250,7 +250,7 @@ struct CheatWindow : Window { uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH); uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH : 0); - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; int box_y_offset = (this->line_height - this->box.height) / 2; int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; int icon_y_offset = (this->line_height - this->icon.height) / 2; @@ -339,7 +339,7 @@ struct CheatWindow : Window { this->line_height = std::max(this->box.height, this->icon.height); this->line_height = std::max(this->line_height, SETTING_BUTTON_HEIGHT); - this->line_height = std::max(this->line_height, FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.Vertical(); + this->line_height = std::max(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical(); size->width = width + WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + WidgetDimensions::scaled.hsep_wide * 2 /* extra spacing on right */; size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui); diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 5a54787b41..6e7e41b871 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -91,7 +91,7 @@ struct ExpensesList { uint GetHeight() const { /* Add up the height of all the lines. */ - return static_cast(this->items.size()) * FONT_HEIGHT_NORMAL; + return static_cast(this->items.size()) * GetCharacterHeight(FS_NORMAL); } /** Compute width of the expenses categories in pixels. */ @@ -119,15 +119,15 @@ static const std::initializer_list _expenses_list_types = { static uint GetTotalCategoriesHeight() { /* There's an empty line and blockspace on the year row */ - uint total_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + uint total_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; for (const ExpensesList &list : _expenses_list_types) { /* Title + expense list + total line + total + blockspace after category */ - total_height += FONT_HEIGHT_NORMAL + list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + total_height += GetCharacterHeight(FS_NORMAL) + list.GetHeight() + WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; } /* Total income */ - total_height += WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + total_height += WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; return total_height; } @@ -162,7 +162,7 @@ static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list) for (const ExpensesType &et : list.items) { DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } } @@ -174,12 +174,12 @@ static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list) static void DrawCategories(const Rect &r) { /* Start with an empty space in the year row, plus the blockspace under the year. */ - int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + int y = r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; for (const ExpensesList &list : _expenses_list_types) { /* Draw category title and advance y */ DrawString(r.left, r.right, y, list.title, TC_FROMSTRING, SA_LEFT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Draw category items and advance y */ DrawCategory(r, y, list); @@ -190,7 +190,7 @@ static void DrawCategories(const Rect &r) /* Draw category total and advance y */ DrawString(r.left, r.right, y, STR_FINANCES_TOTAL_CAPTION, TC_FROMSTRING, SA_RIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); /* Advance y by a blockspace after this category block */ y += WidgetDimensions::scaled.vsep_wide; @@ -235,7 +235,7 @@ static Money DrawYearCategory(const Rect &r, int start_y, const ExpensesList &li Money cost = tbl[et]; sum += cost; if (cost != 0) DrawPrice(cost, r.left, r.right, y, TC_BLACK); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } /* Draw the total at the bottom of the category. */ @@ -263,14 +263,14 @@ static void DrawYearColumn(const Rect &r, TimerGameCalendar::Year year, const Ex /* Year header */ SetDParam(0, year); DrawString(r.left, r.right, y, STR_FINANCES_YEAR, TC_FROMSTRING, SA_RIGHT, true); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; /* Categories */ for (const ExpensesList &list : _expenses_list_types) { - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); sum += DrawYearCategory(r, y, list, tbl); /* Expense list + expense category title + expense category total + blockspace after category */ - y += list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + y += list.GetHeight() + WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; } /* Total income. */ @@ -405,7 +405,7 @@ struct CompanyFinancesWindow : Window { break; case WID_CF_INTEREST_RATE: - size->height = FONT_HEIGHT_NORMAL; + size->height = GetCharacterHeight(FS_NORMAL); break; } } @@ -586,7 +586,7 @@ public: uint Height() const override { - return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal); + return std::max(GetCharacterHeight(FS_NORMAL), ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal); } bool Selectable() const override @@ -598,7 +598,7 @@ public: { bool rtl = _current_text_dir == TD_RTL; int icon_y = CenterBounds(r.top, r.bottom, 0); - int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL); + int text_y = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext); DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + (this->result % COLOUR_END), rtl ? tr.right - ScaleGUITrad(14) : tr.left + ScaleGUITrad(14), @@ -818,7 +818,7 @@ public: case WID_SCL_MATRIX: { /* 11 items in the default rail class */ this->square = GetSpriteSize(SPR_SQUARE); - this->line_height = std::max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + padding.height; + this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; size->height = 11 * this->line_height; resize->width = 1; @@ -923,7 +923,7 @@ public: Rect ir = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix); int square_offs = (ir.Height() - this->square.height) / 2; - int text_offs = (ir.Height() - FONT_HEIGHT_NORMAL) / 2; + int text_offs = (ir.Height() - GetCharacterHeight(FS_NORMAL)) / 2; int y = ir.top; @@ -1928,7 +1928,7 @@ struct CompanyInfrastructureWindow : Window size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); } - size->height = std::max(size->height, lines * FONT_HEIGHT_NORMAL); + size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); break; } @@ -1945,7 +1945,7 @@ struct CompanyInfrastructureWindow : Window } } - size->height = std::max(size->height, lines * FONT_HEIGHT_NORMAL); + size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); break; } @@ -2006,7 +2006,7 @@ struct CompanyInfrastructureWindow : Window /* Set height of the total line. */ if (widget == WID_CI_TOTAL) { - size->height = _settings_game.economy.infrastructure_maintenance ? std::max(size->height, WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL) : 0; + size->height = _settings_game.economy.infrastructure_maintenance ? std::max(size->height, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)) : 0; } break; } @@ -2023,7 +2023,7 @@ struct CompanyInfrastructureWindow : Window void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const { SetDParam(0, count); - DrawString(r.left, r.right, y += FONT_HEIGHT_NORMAL, STR_JUST_COMMA, TC_WHITE, SA_RIGHT); + DrawString(r.left, r.right, y += GetCharacterHeight(FS_NORMAL), STR_JUST_COMMA, TC_WHITE, SA_RIGHT); if (_settings_game.economy.infrastructure_maintenance) { SetDParam(0, monthly_cost * 12); // Convert to per year @@ -2047,13 +2047,13 @@ struct CompanyInfrastructureWindow : Window /* Draw name of each valid railtype. */ for (const auto &rt : _sorted_railtypes) { if (HasBit(this->railtypes, rt)) { - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, GetRailTypeInfo(rt)->strings.name, TC_WHITE); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), GetRailTypeInfo(rt)->strings.name, TC_WHITE); } } - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS); } else { /* No valid railtype. */ - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_VIEW_INFRASTRUCTURE_NONE); } break; @@ -2079,7 +2079,7 @@ struct CompanyInfrastructureWindow : Window /* Draw name of each valid roadtype. */ for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) { - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, GetRoadTypeInfo(rt)->strings.name, TC_WHITE); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), GetRoadTypeInfo(rt)->strings.name, TC_WHITE); } } @@ -2099,7 +2099,7 @@ struct CompanyInfrastructureWindow : Window case WID_CI_WATER_DESC: DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT); - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS); break; case WID_CI_WATER_COUNT: @@ -2118,8 +2118,8 @@ struct CompanyInfrastructureWindow : Window case WID_CI_STATION_DESC: DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT); - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS); - DrawString(ir.left, ir.right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS); + DrawString(ir.left, ir.right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS); break; case WID_CI_STATION_COUNT: @@ -2418,7 +2418,7 @@ struct CompanyWindow : Window if (amount != 0) { SetDParam(0, amount); DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[type]); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } } @@ -2437,7 +2437,7 @@ struct CompanyWindow : Window if (rail_pieces != 0) { SetDParam(0, rail_pieces); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } uint road_pieces = 0; @@ -2445,25 +2445,25 @@ struct CompanyWindow : Window if (road_pieces != 0) { SetDParam(0, road_pieces); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } if (c->infrastructure.water != 0) { SetDParam(0, c->infrastructure.water); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } if (c->infrastructure.station != 0) { SetDParam(0, c->infrastructure.station); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } if (c->infrastructure.airport != 0) { SetDParam(0, c->infrastructure.airport); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } if (y == r.top) { diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 952a21bb1a..6ac256100c 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -125,7 +125,7 @@ struct IConsoleWindow : Window void OnInit() override { - this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.hsep_normal; + this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.hsep_normal; this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left; } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index de9fd5384a..e001f2fedb 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -330,7 +330,7 @@ struct DepotWindow : Window { SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE)); SetDParam(1, 1); Rect count = text.WithWidth(this->count_width - WidgetDimensions::scaled.hsep_normal, !rtl); - DrawString(count.left, count.right, count.bottom - FONT_HEIGHT_SMALL + 1, STR_JUST_DECIMAL, TC_BLACK, SA_RIGHT, false, FS_SMALL); // Draw the counter + DrawString(count.left, count.right, count.bottom - GetCharacterHeight(FS_SMALL) + 1, STR_JUST_DECIMAL, TC_BLACK, SA_RIGHT, false, FS_SMALL); // Draw the counter break; } @@ -348,10 +348,10 @@ struct DepotWindow : Window { } else { /* Arrange unitnumber and flag vertically */ diff_x = 0; - diff_y = WidgetDimensions::scaled.matrix.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + diff_y = WidgetDimensions::scaled.matrix.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } - text = text.WithWidth(this->header_width - WidgetDimensions::scaled.hsep_normal, rtl).WithHeight(FONT_HEIGHT_NORMAL).Indent(diff_x, rtl); + text = text.WithWidth(this->header_width - WidgetDimensions::scaled.hsep_normal, rtl).WithHeight(GetCharacterHeight(FS_NORMAL)).Indent(diff_x, rtl); if (free_wagon) { DrawString(text, STR_DEPOT_NO_ENGINE); } else { @@ -507,7 +507,7 @@ struct DepotWindow : Window { case VEH_SHIP: case VEH_AIRCRAFT: - if (xm <= this->flag_size.width && ym >= (uint)(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP; + if (xm <= this->flag_size.width && ym >= (uint)(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP; break; default: NOT_REACHED(); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 09d9f6c1f3..f5a969788d 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -100,7 +100,7 @@ struct EnginePreviewWindow : Window { size->width = std::max(size->width, x - x_offs); SetDParam(0, GetEngineCategoryName(engine)); - size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + FONT_HEIGHT_NORMAL + this->vehicle_space; + size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space; SetDParam(0, engine); size->height += GetStringHeight(GetEngineInfoString(engine), size->width); } @@ -115,7 +115,7 @@ struct EnginePreviewWindow : Window { SetDParam(0, PackEngineNameDParam(engine, EngineNameContext::PreviewNews)); DrawString(r.left, r.right, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); DrawVehicleEngine(r.left, r.right, this->width >> 1, y + this->vehicle_space / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 2b794ecd53..c4bbb7aef5 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -431,7 +431,7 @@ public: Rect ir = r.Shrink(WidgetDimensions::scaled.framerect); if (free_space.has_value()) SetDParam(0, free_space.value()); - DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE); + DrawString(ir.left, ir.right, ir.top + GetCharacterHeight(FS_NORMAL), free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE); DrawString(ir.left, ir.right, ir.top, path, TC_BLACK); break; } @@ -465,7 +465,7 @@ public: void DrawDetails(const Rect &r) const { /* Header panel */ - int HEADER_HEIGHT = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical(); + int HEADER_HEIGHT = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical(); Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext); Rect tr = r.Shrink(WidgetDimensions::scaled.frametext); @@ -478,13 +478,13 @@ public: if (this->selected == nullptr) return; /* Details panel */ - tr.bottom -= FONT_HEIGHT_NORMAL - 1; + tr.bottom -= GetCharacterHeight(FS_NORMAL) - 1; if (tr.top > tr.bottom) return; if (!_load_check_data.checkable) { /* Old savegame, no information available */ DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } else if (_load_check_data.error != INVALID_STRING_ID) { /* Incompatible / broken savegame */ SetDParamStr(0, _load_check_data.error_msg); @@ -494,7 +494,7 @@ public: SetDParam(0, _load_check_data.map_size_x); SetDParam(1, _load_check_data.map_size_y); DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); if (tr.top > tr.bottom) return; /* Climate */ @@ -502,7 +502,7 @@ public: if (landscape < NUM_LANDSCAPE) { SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape); DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } tr.top += WidgetDimensions::scaled.vsep_normal; @@ -512,7 +512,7 @@ public: if (_load_check_data.settings.game_creation.starting_year != 0) { SetDParam(0, TimerGameCalendar::ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1)); DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } if (tr.top > tr.bottom) return; @@ -521,7 +521,7 @@ public: /* Current date */ SetDParam(0, _load_check_data.current_date); DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } /* Hide the NewGRF stuff when saving. We also hide the button. */ @@ -533,7 +533,7 @@ public: SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE : STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility); DrawString(tr, STR_SAVELOAD_DETAIL_GRFSTATUS); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } if (tr.top > tr.bottom) return; @@ -554,7 +554,7 @@ public: SetDParam(2, c.name_2); } DrawString(tr, STR_SAVELOAD_DETAIL_COMPANY_INDEX); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); if (tr.top > tr.bottom) break; } } @@ -565,11 +565,11 @@ public: { switch (widget) { case WID_SL_BACKGROUND: - size->height = 2 * FONT_HEIGHT_NORMAL + padding.height; + size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; break; case WID_SL_DRIVES_DIRECTORIES_LIST: - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); size->height = resize->height * 10 + padding.height; break; case WID_SL_SORT_BYNAME: diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 23fe4d000c..4406b97879 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -457,7 +457,7 @@ struct FramerateWindow : Window { this->num_displayed = this->num_active; /* Window is always initialised to MIN_ELEMENTS height, resize to contain num_displayed */ - ResizeWindow(this, 0, (std::max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * FONT_HEIGHT_NORMAL); + ResizeWindow(this, 0, (std::max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * GetCharacterHeight(FS_NORMAL)); } void OnRealtimeTick([[maybe_unused]] uint delta_ms) override @@ -563,9 +563,9 @@ struct FramerateWindow : Window { case WID_FRW_TIMES_NAMES: { size->width = 0; - size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * FONT_HEIGHT_NORMAL; + size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL); resize->width = 0; - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); for (PerformanceElement e : DISPLAY_ORDER_PFE) { if (_pf_data[e].num_valid == 0) continue; Dimension line_size; @@ -589,9 +589,9 @@ struct FramerateWindow : Window { SetDParam(1, 2); Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD); size->width = std::max(size->width, item_size.width); - size->height += FONT_HEIGHT_NORMAL * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal; + size->height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal; resize->width = 0; - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); break; } } @@ -605,7 +605,7 @@ struct FramerateWindow : Window { int drawable = this->num_displayed; int y = r.top; DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; for (PerformanceElement e : DISPLAY_ORDER_PFE) { if (_pf_data[e].num_valid == 0) continue; if (skip > 0) { @@ -613,7 +613,7 @@ struct FramerateWindow : Window { } else { values[e].InsertDParams(0); DrawString(r.left, r.right, y, values[e].strid, TC_FROMSTRING, SA_RIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); drawable--; if (drawable == 0) break; } @@ -627,7 +627,7 @@ struct FramerateWindow : Window { int drawable = this->num_displayed; int y = r.top; DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; for (PerformanceElement e : DISPLAY_ORDER_PFE) { if (_pf_data[e].num_valid == 0) continue; if (skip > 0) { @@ -639,12 +639,12 @@ struct FramerateWindow : Window { SetDParam(0, Company::Get(e - PFE_AI0)->ai_instance->GetAllocatedMemory()); } DrawString(r.left, r.right, y, STR_FRAMERATE_BYTES_GOOD, TC_FROMSTRING, SA_RIGHT); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); drawable--; if (drawable == 0) break; } else { /* skip non-script */ - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); drawable--; if (drawable == 0) break; } @@ -659,7 +659,7 @@ struct FramerateWindow : Window { const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); uint16_t skip = sb->GetPosition(); int drawable = this->num_displayed; - int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns + int y = r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns for (PerformanceElement e : DISPLAY_ORDER_PFE) { if (_pf_data[e].num_valid == 0) continue; if (skip > 0) { @@ -672,7 +672,7 @@ struct FramerateWindow : Window { SetDParamStr(1, GetAIName(e - PFE_AI0)); DrawString(r.left, r.right, y, STR_FRAMERATE_AI, TC_FROMSTRING, SA_LEFT); } - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); drawable--; if (drawable == 0) break; } @@ -701,7 +701,7 @@ struct FramerateWindow : Window { case WID_FRW_TIMES_AVERAGE: { /* Open time graph windows when clicking detail measurement lines */ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); - int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL); + int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)); if (line != INT_MAX) { line++; /* Find the visible line that was clicked */ @@ -721,7 +721,7 @@ struct FramerateWindow : Window { void OnResize() override { auto *wid = this->GetWidget(WID_FRW_TIMES_NAMES); - this->num_displayed = (wid->current_y - wid->min_y - WidgetDimensions::scaled.vsep_normal) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings + this->num_displayed = (wid->current_y - wid->min_y - WidgetDimensions::scaled.vsep_normal) / GetCharacterHeight(FS_NORMAL) - 1; // subtract 1 for headings this->GetScrollbar(WID_FRW_SCROLLBAR)->SetCapacity(this->num_displayed); } }; @@ -929,10 +929,10 @@ struct FrametimeGraphWindow : Window { if (division % 2 == 0) { if ((TimingMeasurement)this->vertical_scale > TIMESTAMP_PRECISION) { SetDParam(0, this->vertical_scale * division / 10 / TIMESTAMP_PRECISION); - DrawString(r.left, x_zero - 2, y - FONT_HEIGHT_SMALL, STR_FRAMERATE_GRAPH_SECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL); + DrawString(r.left, x_zero - 2, y - GetCharacterHeight(FS_SMALL), STR_FRAMERATE_GRAPH_SECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL); } else { SetDParam(0, this->vertical_scale * division / 10 * 1000 / TIMESTAMP_PRECISION); - DrawString(r.left, x_zero - 2, y - FONT_HEIGHT_SMALL, STR_FRAMERATE_GRAPH_MILLISECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL); + DrawString(r.left, x_zero - 2, y - GetCharacterHeight(FS_SMALL), STR_FRAMERATE_GRAPH_MILLISECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL); } } } @@ -1000,7 +1000,7 @@ struct FrametimeGraphWindow : Window { TextColour tc_peak = (TextColour)(TC_IS_PALETTE_COLOUR | c_peak); GfxFillRect(peak_point.x - 1, peak_point.y - 1, peak_point.x + 1, peak_point.y + 1, c_peak); SetDParam(0, peak_value * 1000 / TIMESTAMP_PRECISION); - int label_y = std::max(y_max, peak_point.y - FONT_HEIGHT_SMALL); + int label_y = std::max(y_max, peak_point.y - GetCharacterHeight(FS_SMALL)); if (peak_point.x - x_zero > (int)this->graph_size.width / 2) { DrawString(x_zero, peak_point.x - 2, label_y, STR_FRAMERATE_GRAPH_MILLISECONDS, tc_peak, SA_RIGHT | SA_FORCE, false, FS_SMALL); } else { diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 2e1e737e82..0994d7def5 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -136,14 +136,14 @@ struct GSConfigWindow : public Window { { switch (widget) { case WID_GSC_SETTINGS: - this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height; + this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; resize->width = 1; resize->height = this->line_height; size->height = 5 * this->line_height; break; case WID_GSC_GSLIST: - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; size->height = 1 * this->line_height; break; } @@ -186,7 +186,7 @@ struct GSConfigWindow : public Window { int y = r.top; int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) { const ScriptConfigItem &config_item = **it; int current_value = config->GetSetting((config_item).name); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index d9f659dbf1..3300f2ef1c 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -572,7 +572,7 @@ struct GenerateLandscapeWindow : public Window { void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { - Dimension d{0, (uint)FONT_HEIGHT_NORMAL}; + Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; const StringID *strs = nullptr; switch (widget) { case WID_GL_HEIGHTMAP_HEIGHT_TEXT: @@ -1408,7 +1408,7 @@ struct GenerateProgressWindow : public Window { for (uint i = 0; i < GWP_CLASS_COUNT; i++) { size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width); } - size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal; + size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } @@ -1422,7 +1422,7 @@ struct GenerateProgressWindow : public Window { Rect br = r.Shrink(WidgetDimensions::scaled.bevel); DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE); SetDParam(0, _gws.percent); - DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); break; } @@ -1433,7 +1433,7 @@ struct GenerateProgressWindow : public Window { /* And say where we are in that class */ SetDParam(0, _gws.current); SetDParam(1, _gws.total); - DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER); } } }; diff --git a/src/gfx.cpp b/src/gfx.cpp index c6dcfce611..b261845f0d 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -647,7 +647,7 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left, int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) { /* The string may contain control chars to change the font, just use the biggest font for clipping. */ - int max_height = std::max({FONT_HEIGHT_SMALL, FONT_HEIGHT_NORMAL, FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO}); + int max_height = std::max({GetCharacterHeight(FS_SMALL), GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_LARGE), GetCharacterHeight(FS_MONO)}); /* Funny glyphs may extent outside the usual bounds, so relax the clipping somewhat. */ int extra = max_height / 2; @@ -915,7 +915,7 @@ void DrawCharCentered(char32_t c, const Rect &r, TextColour colour) SetColourRemap(colour); GfxMainBlitter(GetGlyph(FS_NORMAL, c), CenterBounds(r.left, r.right, GetCharacterWidth(FS_NORMAL, c)), - CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), + CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), BM_COLOUR_REMAP); } diff --git a/src/gfx_func.h b/src/gfx_func.h index 82c654a598..c0610e43ea 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -183,18 +183,6 @@ void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL); int GetCharacterHeight(FontSize size); -/** Height of characters in the small (#FS_SMALL) font. @note Some characters may be oversized. */ -#define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) - -/** Height of characters in the normal (#FS_NORMAL) font. @note Some characters may be oversized. */ -#define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) - -/** Height of characters in the large (#FS_LARGE) font. @note Some characters may be oversized. */ -#define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE)) - -/** Height of characters in the large (#FS_MONO) font. @note Some characters may be oversized. */ -#define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) - extern DrawPixelInfo *_cur_dpi; /** diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index adf3345ba4..774230c0f6 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -219,7 +219,7 @@ struct GoalListWindow : public Window { } break; } - r.top += FONT_HEIGHT_NORMAL; + r.top += GetCharacterHeight(FS_NORMAL); } pos++; num++; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index c84eaf8b08..4faad7b7fc 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -73,7 +73,7 @@ struct GraphLegendWindow : Window { const Rect tr = ir.Indent(d.width + WidgetDimensions::scaled.hsep_normal, rtl); SetDParam(0, cid); SetDParam(1, cid); - DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); + DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); } void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override @@ -524,7 +524,7 @@ public: uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width; size->width = std::max(size->width, ScaleGUITrad(5) + y_label_width + this->num_on_x_axis * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9)); - size->height = std::max(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * FONT_HEIGHT_SMALL + ScaleGUITrad(4)); + size->height = std::max(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4)); size->height = std::max(size->height, size->width / 3); } @@ -901,7 +901,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { void OnInit() override { /* Width of the legend blob. */ - this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5; + this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 8 / 5; } void UpdateExcludedData() @@ -922,7 +922,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { return; } - size->height = FONT_HEIGHT_SMALL + WidgetDimensions::scaled.framerect.Vertical(); + size->height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical(); for (const CargoSpec *cs : _sorted_standard_cargo_specs) { SetDParam(0, cs->name); @@ -1147,7 +1147,7 @@ struct PerformanceRatingDetailWindow : Window { { switch (widget) { case WID_PRD_SCORE_FIRST: - this->bar_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.Vertical(); + this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical(); size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical(); uint score_info_width = 0; @@ -1235,7 +1235,7 @@ struct PerformanceRatingDetailWindow : Window { } uint bar_top = CenterBounds(r.top, r.bottom, this->bar_height); - uint text_top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL); + uint text_top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index b9825a40b8..929e01509b 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -582,12 +582,12 @@ public: SetDParam(0, this_year); DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); DrawString(tr, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK); SetDParam(0, last_year); DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); DrawString(tr, STR_GROUP_OCCUPANCY, TC_BLACK); const size_t vehicle_count = this->vehicles.size(); if (vehicle_count > 0) { diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 3849d7b027..a6c9529af4 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -204,7 +204,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140 + i * 55), STR_JUST_BIG_RAW_STRING, colour); SetDParam(0, hs[i].title); SetDParam(1, hs[i].score); - DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140) + FONT_HEIGHT_LARGE + ScaleSpriteTrad(i * 55), STR_HIGHSCORE_STATS, colour); + DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140) + GetCharacterHeight(FS_LARGE) + ScaleSpriteTrad(i * 55), STR_HIGHSCORE_STATS, colour); } } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 318ad6748a..ef42146b5b 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -418,7 +418,7 @@ public: void OnInit() override { /* Width of the legend blob -- slightly larger than the smallmap legend blob. */ - this->legend.height = FONT_HEIGHT_SMALL; + this->legend.height = GetCharacterHeight(FS_SMALL); this->legend.width = this->legend.height * 8 / 5; this->SetupArrays(); @@ -432,7 +432,7 @@ public: for (const auto &indtype : this->list) { d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name)); } - resize->height = std::max(this->legend.height, FONT_HEIGHT_NORMAL) + padding.height; + resize->height = std::max(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height; d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width; d.height = 5 * resize->height; *size = maxdim(*size, d); @@ -445,7 +445,7 @@ public: uint extra_lines_req = 0; uint extra_lines_prd = 0; uint extra_lines_newgrf = 0; - uint max_minwidth = FONT_HEIGHT_NORMAL * MAX_MINWIDTH_LINEHEIGHTS; + uint max_minwidth = GetCharacterHeight(FS_NORMAL) * MAX_MINWIDTH_LINEHEIGHTS; Dimension d = {0, 0}; for (const auto &indtype : this->list) { const IndustrySpec *indsp = GetIndustrySpec(indtype); @@ -479,7 +479,7 @@ public: /* Set it to something more sane :) */ height += extra_lines_prd + extra_lines_req + extra_lines_newgrf; - size->height = height * FONT_HEIGHT_NORMAL + padding.height; + size->height = height * GetCharacterHeight(FS_NORMAL) + padding.height; size->width = d.width + padding.width; break; } @@ -561,7 +561,7 @@ public: if (_game_mode != GM_EDITOR) { SetDParam(0, indsp->GetConstructionCost()); DrawString(ir, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST); - ir.top += FONT_HEIGHT_NORMAL; + ir.top += GetCharacterHeight(FS_NORMAL); } CargoSuffix cargo_suffix[lengthof(indsp->accepts_cargo)]; @@ -817,7 +817,7 @@ public: this->editbox_line = IL_NONE; this->clicked_line = IL_NONE; this->clicked_button = 0; - this->info_height = WidgetDimensions::scaled.framerect.Vertical() + 2 * FONT_HEIGHT_NORMAL; // Info panel has at least two lines text. + this->info_height = WidgetDimensions::scaled.framerect.Vertical() + 2 * GetCharacterHeight(FS_NORMAL); // Info panel has at least two lines text. this->InitNested(window_number); NWidgetViewport *nvp = this->GetWidget(WID_IV_VIEWPORT); @@ -829,7 +829,7 @@ public: void OnInit() override { /* This only used when the cheat to alter industry production is enabled */ - this->cheat_line_height = std::max(SETTING_BUTTON_HEIGHT + WidgetDimensions::scaled.vsep_normal, FONT_HEIGHT_NORMAL); + this->cheat_line_height = std::max(SETTING_BUTTON_HEIGHT + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FS_NORMAL)); } void OnPaint() override @@ -863,7 +863,7 @@ public: if (i->prod_level == PRODLEVEL_CLOSURE) { DrawString(ir, STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE); - ir.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + ir.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; } bool stockpiling = HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS); @@ -873,7 +873,7 @@ public: has_accept = true; if (first) { DrawString(ir, STR_INDUSTRY_VIEW_REQUIRES); - ir.top += FONT_HEIGHT_NORMAL; + ir.top += GetCharacterHeight(FS_NORMAL); first = false; } @@ -904,11 +904,11 @@ public: NOT_REACHED(); } DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent, rtl), str); - ir.top += FONT_HEIGHT_NORMAL; + ir.top += GetCharacterHeight(FS_NORMAL); } - int line_height = this->editable == EA_RATE ? this->cheat_line_height : FONT_HEIGHT_NORMAL; - int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2; + int line_height = this->editable == EA_RATE ? this->cheat_line_height : GetCharacterHeight(FS_NORMAL); + int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2; int button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2; first = true; for (const auto &p : i->produced) { @@ -916,7 +916,7 @@ public: if (first) { if (has_accept) ir.top += WidgetDimensions::scaled.vsep_wide; DrawString(ir, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE); - ir.top += FONT_HEIGHT_NORMAL; + ir.top += GetCharacterHeight(FS_NORMAL); if (this->editable == EA_RATE) this->production_offset_y = ir.top; first = false; } @@ -940,7 +940,7 @@ public: /* Display production multiplier if editable */ if (this->editable == EA_MULTIPLIER) { line_height = this->cheat_line_height; - text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2; + text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2; button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2; ir.top += WidgetDimensions::scaled.vsep_wide; this->production_offset_y = ir.top; @@ -2138,7 +2138,7 @@ struct CargoesField { break; case CFT_HEADER: - ypos += (small_height - FONT_HEIGHT_NORMAL) / 2; + ypos += (small_height - GetCharacterHeight(FS_NORMAL)) / 2; DrawString(xpos, xpos + industry_width, ypos, this->u.header, TC_WHITE, SA_HOR_CENTER); break; @@ -2150,7 +2150,7 @@ struct CargoesField { GfxDrawLine(xpos, ypos1, xpos, ypos2, INDUSTRY_LINE_COLOUR); GfxDrawLine(xpos, ypos2, xpos2, ypos2, INDUSTRY_LINE_COLOUR); GfxDrawLine(xpos2, ypos1, xpos2, ypos2, INDUSTRY_LINE_COLOUR); - ypos += (normal_height - FONT_HEIGHT_NORMAL) / 2; + ypos += (normal_height - GetCharacterHeight(FS_NORMAL)) / 2; if (this->u.industry.ind_type < NUM_INDUSTRYTYPES) { const IndustrySpec *indsp = GetIndustrySpec(this->u.industry.ind_type); DrawString(xpos, xpos2, ypos, indsp->name, TC_WHITE, SA_HOR_CENTER); @@ -2179,7 +2179,7 @@ struct CargoesField { other_right = this->u.industry.other_produced; other_left = this->u.industry.other_accepted; } - ypos1 += CargoesField::cargo_border.height + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2; + ypos1 += CargoesField::cargo_border.height + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2; for (uint i = 0; i < CargoesField::max_cargoes; i++) { if (IsValidCargoID(other_right[i])) { const CargoSpec *csp = CargoSpec::Get(other_right[i]); @@ -2193,7 +2193,7 @@ struct CargoesField { DrawHorConnection(xp + 1, xpos - 1, ypos1, csp); GfxDrawLine(xp, ypos1, xp, ypos1 + CargoesField::cargo_line.height - 1, CARGO_LINE_COLOUR); } - ypos1 += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height; + ypos1 += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height; } break; } @@ -2223,7 +2223,7 @@ struct CargoesField { hor_left = this->u.cargo.supp_cargoes; hor_right = this->u.cargo.cust_cargoes; } - ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2; + ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2; for (uint i = 0; i < MAX_CARGOES; i++) { if (IsValidCargoID(hor_left[i])) { int col = hor_left[i]; @@ -2247,7 +2247,7 @@ struct CargoesField { } DrawHorConnection(cargo_base + col * CargoesField::cargo_space.width + (col + 1) * CargoesField::cargo_line.width - 1 + dx, xpos + CargoesField::cargo_field_width - 1, ypos, csp); } - ypos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height; + ypos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height; } break; } @@ -2260,7 +2260,7 @@ struct CargoesField { DrawString(xpos + WidgetDimensions::scaled.framerect.left, xpos + industry_width - 1 - WidgetDimensions::scaled.framerect.right, ypos, csp->name, TC_WHITE, (this->u.cargo_label.left_align) ? SA_LEFT : SA_RIGHT); } - ypos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height; + ypos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height; } break; @@ -2294,8 +2294,8 @@ struct CargoesField { uint row; for (row = 0; row < MAX_CARGOES; row++) { if (pt.y < vpos) return CT_INVALID; - if (pt.y < vpos + FONT_HEIGHT_NORMAL) break; - vpos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.width; + if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break; + vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.width; } if (row == MAX_CARGOES) return CT_INVALID; @@ -2342,8 +2342,8 @@ struct CargoesField { uint row; for (row = 0; row < MAX_CARGOES; row++) { if (pt.y < vpos) return CT_INVALID; - if (pt.y < vpos + FONT_HEIGHT_NORMAL) break; - vpos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height; + if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break; + vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height; } if (row == MAX_CARGOES) return CT_INVALID; return this->u.cargo_label.cargoes[row]; @@ -2551,7 +2551,7 @@ struct IndustryCargoesWindow : public Window { CargoesField::small_height = d.height; /* Size of the legend blob -- slightly larger than the smallmap legend blob. */ - CargoesField::legend.height = FONT_HEIGHT_SMALL; + CargoesField::legend.height = GetCharacterHeight(FS_SMALL); CargoesField::legend.width = CargoesField::legend.height * 8 / 5; /* Size of cargo lines. */ @@ -2600,7 +2600,7 @@ struct IndustryCargoesWindow : public Window { d.width += WidgetDimensions::scaled.frametext.Horizontal(); /* Ensure the height is enough for the industry type text, for the horizontal connections, and for the cargo labels. */ - uint min_ind_height = CargoesField::cargo_border.height * 2 + CargoesField::max_cargoes * FONT_HEIGHT_NORMAL + (CargoesField::max_cargoes - 1) * CargoesField::cargo_space.height; + uint min_ind_height = CargoesField::cargo_border.height * 2 + CargoesField::max_cargoes * GetCharacterHeight(FS_NORMAL) + (CargoesField::max_cargoes - 1) * CargoesField::cargo_space.height; d.height = std::max(d.height + WidgetDimensions::scaled.frametext.Vertical(), min_ind_height); CargoesField::industry_width = d.width; diff --git a/src/league_gui.cpp b/src/league_gui.cpp index a1c64a6c8f..e113c29613 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -106,7 +106,7 @@ public: Rect ir = r.Shrink(WidgetDimensions::scaled.framerect); int icon_y_offset = (this->line_height - this->icon.height) / 2; - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; bool rtl = _current_text_dir == TD_RTL; Rect ordinal = ir.WithWidth(this->ordinal_width, rtl); @@ -148,7 +148,7 @@ public: } this->icon = GetSpriteSize(SPR_COMPANY_ICON); - this->line_height = std::max(this->icon.height + WidgetDimensions::scaled.vsep_normal, FONT_HEIGHT_NORMAL); + this->line_height = std::max(this->icon.height + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FS_NORMAL)); for (const Company *c : Company::Iterate()) { SetDParam(0, c->index); @@ -328,7 +328,7 @@ public: } int icon_y_offset = (this->line_height - this->icon_size.height) / 2; - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; /* Calculate positions.of the columns */ bool rtl = _current_text_dir == TD_RTL; @@ -363,7 +363,7 @@ public: if (lt == nullptr) return; this->icon_size = GetSpriteSize(SPR_COMPANY_ICON); - this->line_height = std::max(this->icon_size.height + WidgetDimensions::scaled.fullbevel.Vertical(), FONT_HEIGHT_NORMAL); + this->line_height = std::max(this->icon_size.height + WidgetDimensions::scaled.fullbevel.Vertical(), GetCharacterHeight(FS_NORMAL)); /* Calculate maximum width of every column */ this->rank_width = this->text_width = this->score_width = 0; diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 23bcd1b852..07393d69cc 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -633,13 +633,13 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const str = STR_LINKGRAPH_LEGEND_SATURATED; } if (str != STR_NULL) { - DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER, false, FS_SMALL); + DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER, false, FS_SMALL); } } if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) { const CargoSpec *cargo = _sorted_cargo_specs[widget - WID_LGL_CARGO_FIRST]; GfxFillRect(br, cargo->legend_colour); - DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER, false, FS_SMALL); + DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER, false, FS_SMALL); } } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 49dd4cc552..96617d8cf0 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -79,7 +79,7 @@ public: Rect ir = r.Shrink(WidgetDimensions::scaled.frametext); for (size_t i = 0; i < this->landinfo_data.size(); i++) { DrawString(ir, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_HOR_CENTER); - ir.top += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); + ir.top += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); } if (!this->cargo_acceptance.empty()) { @@ -97,7 +97,7 @@ public: uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal(); size->width = std::max(size->width, width); - size->height += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); + size->height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); } if (!this->cargo_acceptance.empty()) { @@ -488,7 +488,7 @@ struct AboutWindow : public Window { { if (widget != WID_A_SCROLLING_TEXT) return; - this->line_height = FONT_HEIGHT_NORMAL; + this->line_height = GetCharacterHeight(FS_NORMAL); Dimension d; d.height = this->line_height * num_visible_lines; @@ -518,9 +518,9 @@ struct AboutWindow : public Window { /** * Scroll the text in the about window slow. * - * The interval of 2100ms is chosen to maintain parity: 2100 / FONT_HEIGHT_NORMAL = 150ms. + * The interval of 2100ms is chosen to maintain parity: 2100 / GetCharacterHeight(FS_NORMAL) = 150ms. */ - IntervalTimer scroll_interval = {std::chrono::milliseconds(2100) / FONT_HEIGHT_NORMAL, [this](uint count) { + IntervalTimer scroll_interval = {std::chrono::milliseconds(2100) / GetCharacterHeight(FS_NORMAL), [this](uint count) { this->text_position -= count; /* If the last text has scrolled start a new from the start */ if (this->text_position < (int)(this->GetWidget(WID_A_SCROLLING_TEXT)->pos_y - lengthof(_credits) * this->line_height)) { diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 0a521e189e..0d6ee8e481 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -539,7 +539,7 @@ struct MusicTrackSelectionWindow : public Window { SetDParam(1, 2); SetDParamStr(2, song.songname); DrawString(tr, STR_PLAYLIST_TRACK_NAME); - tr.top += FONT_HEIGHT_SMALL; + tr.top += GetCharacterHeight(FS_SMALL); } break; } @@ -553,7 +553,7 @@ struct MusicTrackSelectionWindow : public Window { SetDParam(1, 2); SetDParamStr(2, song.songname); DrawString(tr, STR_PLAYLIST_TRACK_NAME); - tr.top += FONT_HEIGHT_SMALL; + tr.top += GetCharacterHeight(FS_SMALL); } break; } @@ -564,13 +564,13 @@ struct MusicTrackSelectionWindow : public Window { { switch (widget) { case WID_MTS_LIST_LEFT: { // add to playlist - int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL); + int y = this->GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL)); _music.PlaylistAdd(y); break; } case WID_MTS_LIST_RIGHT: { // remove from playlist - int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL); + int y = this->GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL)); _music.PlaylistRemove(y); break; } diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index cdb2d1fba1..bab250f482 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -101,8 +101,8 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::st /** Initialize all font-dependent chat box sizes. */ void NetworkReInitChatBoxSize() { - _chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL; - _chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4); + _chatmsg_box.y = 3 * GetCharacterHeight(FS_NORMAL); + _chatmsg_box.height = MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4); } /** Initialize all buffers of the chat visualisation. */ @@ -218,10 +218,10 @@ void NetworkDrawChatMessage() for (auto &cmsg : _chatmsg_list) { if (!show_all && cmsg.remove_time < now) continue; SetDParamStr(0, cmsg.message); - string_height += GetStringLineCount(STR_JUST_RAW_STRING, width - 1) * FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING; + string_height += GetStringLineCount(STR_JUST_RAW_STRING, width - 1) * GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING; } - string_height = std::min(string_height, MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING)); + string_height = std::min(string_height, MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING)); int top = _screen.height - _chatmsg_box.y - string_height - 2; int bottom = _screen.height - _chatmsg_box.y - 2; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 3673c94acb..335e803e66 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -128,7 +128,7 @@ void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimens break; case WID_NCDS_PROGRESS_TEXT: - size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal; + size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } @@ -144,7 +144,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge SetDParam(0, this->downloaded_bytes); SetDParam(1, this->total_bytes); SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes); - DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER); break; } @@ -598,7 +598,7 @@ public: } case WID_NCL_MATRIX: - resize->height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + padding.height; + resize->height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; size->height = 10 * resize->height; break; } @@ -647,7 +647,7 @@ public: /* Fill the matrix with the information */ int sprite_y_offset = (this->resize.step_height - this->checkbox_size.height) / 2; - int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2; Rect mr = r.WithHeight(this->resize.step_height); auto iter = this->content.begin() + this->vscroll->GetPosition(); @@ -686,7 +686,7 @@ public: void DrawDetails(const Rect &r) const { /* Height for the title banner */ - int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical(); + int HEADER_HEIGHT = 3 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical(); Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext); Rect tr = r.Shrink(WidgetDimensions::scaled.frametext); @@ -698,15 +698,15 @@ public: /* Draw the total download size */ SetDParam(0, this->filesize_sum); - DrawString(tr.left, tr.right, tr.bottom - FONT_HEIGHT_NORMAL + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE); + DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL) + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE); if (this->selected == nullptr) return; /* And fill the rest of the details when there's information to place there */ - DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER); + DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER); /* Also show the total download size, so keep some space from the bottom */ - tr.bottom -= FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + tr.bottom -= GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide; if (this->selected->upgrade) { SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e64f393fc4..e92f573fb4 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -352,7 +352,7 @@ protected: } /* offsets to vertically centre text and icons */ - int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2 + 1; + int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2 + 1; int icon_y_offset = (this->resize.step_height - GetSpriteSize(SPR_BLOT).height) / 2; int lock_y_offset = (this->resize.step_height - GetSpriteSize(SPR_LOCK).height) / 2; @@ -468,13 +468,13 @@ public: { switch (widget) { case WID_NG_MATRIX: - resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + padding.height; + resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; fill->height = resize->height; size->height = 12 * resize->height; break; case WID_NG_LASTJOINED: - size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(); + size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical(); break; case WID_NG_LASTJOINED_SPACER: @@ -586,7 +586,7 @@ public: NetworkGameList *sel = this->server; /* Height for the title banner */ - int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical(); + int HEADER_HEIGHT = 3 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical(); Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext); Rect tr = r.Shrink(WidgetDimensions::scaled.frametext); @@ -610,45 +610,45 @@ public: } DrawString(hr.left, hr.right, hr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline - DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name + DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name DrawString(tr.left, tr.right, tr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline } else { // show game info DrawString(hr.left, hr.right, hr.top, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER); - DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name + DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name SetDParam(0, sel->info.clients_on); SetDParam(1, sel->info.clients_max); SetDParam(2, sel->info.companies_on); SetDParam(3, sel->info.companies_max); DrawString(tr, STR_NETWORK_SERVER_LIST_CLIENTS); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + sel->info.landscape); DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, sel->info.map_width); SetDParam(1, sel->info.map_height); DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParamStr(0, sel->info.server_revision); DrawString(tr, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParamStr(0, sel->connection_string); StringID invite_or_address = StrStartsWith(sel->connection_string, "+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS; DrawString(tr, invite_or_address); // server address / invite code - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, sel->info.start_date); DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE); // start date - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, sel->info.game_date); DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); if (sel->info.gamescript_version != -1) { SetDParamStr(0, sel->info.gamescript_name); @@ -1682,7 +1682,7 @@ public: case WID_CL_MATRIX: { uint height = std::max({GetSpriteSize(SPR_COMPANY_ICON).height, GetSpriteSize(SPR_JOIN).height, GetSpriteSize(SPR_ADMIN).height, GetSpriteSize(SPR_CHAT).height}); height += WidgetDimensions::scaled.framerect.Vertical(); - this->line_height = std::max(height, (uint)FONT_HEIGHT_NORMAL) + padding.height; + this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; resize->width = 1; resize->height = this->line_height; @@ -1947,7 +1947,7 @@ public: void DrawCompany(CompanyID company_id, const Rect &r, uint &line) const { bool rtl = _current_text_dir == TD_RTL; - int text_y_offset = CenterBounds(0, this->line_height, FONT_HEIGHT_NORMAL); + int text_y_offset = CenterBounds(0, this->line_height, GetCharacterHeight(FS_NORMAL)); Dimension d = GetSpriteSize(SPR_COMPANY_ICON); int offset = CenterBounds(0, this->line_height, d.height); @@ -2125,7 +2125,7 @@ struct NetworkJoinStatusWindow : Window { break; } DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, false), COLOUR_MAUVE, FR_NONE); - DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER); break; } diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 4fdc4d509b..11322c2019 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -377,7 +377,7 @@ struct NewGRFInspectWindow : Window { } case WID_NGRFI_MAINPANEL: - resize->height = std::max(11, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal); + resize->height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal); resize->width = 1; size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); @@ -879,7 +879,7 @@ struct SpriteAlignerWindow : Window { case WID_SA_LIST: SetDParamMaxDigits(0, 6); size->width = GetStringBoundingBox(STR_JUST_COMMA).width + padding.width; - resize->height = FONT_HEIGHT_NORMAL + padding.height; + resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; resize->width = 1; fill->height = resize->height; break; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 215427f00a..1a5b32c2dc 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -215,8 +215,8 @@ struct NewGRFParametersWindow : public Window { switch (widget) { case WID_NP_NUMPAR_DEC: case WID_NP_NUMPAR_INC: { - size->width = std::max(SETTING_BUTTON_WIDTH / 2, FONT_HEIGHT_NORMAL); - size->height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL); + size->width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL)); + size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)); break; } @@ -230,7 +230,7 @@ struct NewGRFParametersWindow : public Window { } case WID_NP_BACKGROUND: - this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height; + this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; resize->width = 1; resize->height = this->line_height; @@ -239,7 +239,7 @@ struct NewGRFParametersWindow : public Window { case WID_NP_DESCRIPTION: /* Minimum size of 4 lines. The 500 is the default size of the window. */ - Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)FONT_HEIGHT_NORMAL * 4 + WidgetDimensions::scaled.frametext.Vertical()}; + Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)GetCharacterHeight(FS_NORMAL) * 4 + WidgetDimensions::scaled.frametext.Vertical()}; for (const auto &par_info : this->grf_config->param_info) { if (!par_info.has_value()) continue; const char *desc = GetGRFStringFromGRFText(par_info->desc); @@ -281,7 +281,7 @@ struct NewGRFParametersWindow : public Window { Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl); int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { GRFParameterInfo &par_info = this->GetParameterInfo(i); uint32_t current_value = par_info.GetValue(this->grf_config); @@ -747,7 +747,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_FILE_LIST: { Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); - resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL); + resize->height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); size->height = std::max(size->height, padding.height + 6 * resize->height); break; } @@ -755,7 +755,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_AVAIL_LIST: { Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); - resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL); + resize->height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); size->height = std::max(size->height, padding.height + 8 * resize->height); break; } @@ -768,7 +768,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } case WID_NS_NEWGRF_INFO: - size->height = std::max(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * FONT_HEIGHT_NORMAL); + size->height = std::max(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL)); break; case WID_NS_PRESET_LIST: { @@ -861,7 +861,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { Dimension warning = GetSpriteSize(SPR_WARNING_SIGN); int square_offset_y = (step_height - square.height) / 2; int warning_offset_y = (step_height - warning.height) / 2; - int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; + int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2; bool rtl = _current_text_dir == TD_RTL; uint text_left = rtl ? tr.left : tr.left + square.width + 13; @@ -906,7 +906,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); uint step_height = this->GetWidget(WID_NS_AVAIL_LIST)->resize_y; - int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; + int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2; uint min_index = this->vscroll2->GetPosition(); uint max_index = std::min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size()); @@ -925,7 +925,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_NEWGRF_INFO_TITLE: { /* Create the nice grayish rectangle at the details top. */ GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_DARK_BLUE); - DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER); break; } @@ -2103,7 +2103,7 @@ struct SavePresetWindow : public Window { { switch (widget) { case WID_SVP_PRESET_LIST: { - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); size->height = 0; for (uint i = 0; i < this->presets.size(); i++) { Dimension d = GetStringBoundingBox(this->presets[i]); @@ -2124,7 +2124,7 @@ struct SavePresetWindow : public Window { GfxFillRect(br, PC_BLACK); uint step_height = this->GetWidget(WID_SVP_PRESET_LIST)->resize_y; - int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; + int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2; Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); uint min_index = this->vscroll->GetPosition(); uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size()); @@ -2232,7 +2232,7 @@ struct ScanProgressWindow : public Window { /* We really don't know the width. We could determine it by scanning the NewGRFs, * but this is the status window for scanning them... */ size->width = std::max(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width); - size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal; + size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } @@ -2247,7 +2247,7 @@ struct ScanProgressWindow : public Window { uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count); DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, false), COLOUR_MAUVE, FR_NONE); SetDParam(0, percent); - DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); break; } @@ -2256,7 +2256,7 @@ struct ScanProgressWindow : public Window { SetDParam(1, _settings_client.gui.last_newgrf_count); DrawString(r.left, r.right, r.top, STR_NEWGRF_SCAN_STATUS, TC_FROMSTRING, SA_HOR_CENTER); - DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, this->last_name, TC_BLACK, SA_HOR_CENTER); + DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, this->last_name, TC_BLACK, SA_HOR_CENTER); break; } } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index be3c73ad02..2773e6ea53 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -559,9 +559,9 @@ struct NewsWindow : Window { /** * Scroll the news message slowly up from the bottom. * - * The interval of 210ms is chosen to maintain 15ms at normal zoom: 210 / FONT_HEIGHT_NORMAL = 15ms. + * The interval of 210ms is chosen to maintain 15ms at normal zoom: 210 / GetCharacterHeight(FS_NORMAL) = 15ms. */ - IntervalTimer scroll_interval = {std::chrono::milliseconds(210) / FONT_HEIGHT_NORMAL, [this](uint count) { + IntervalTimer scroll_interval = {std::chrono::milliseconds(210) / GetCharacterHeight(FS_NORMAL), [this](uint count) { int newtop = std::max(this->top - 2 * static_cast(count), _screen.height - this->height - this->status_height - this->chat_height); this->SetWindowTop(newtop); }}; @@ -1130,7 +1130,7 @@ struct MessageHistoryWindow : Window { void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_MH_BACKGROUND) { - this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; resize->height = this->line_height; /* Months are off-by-one, so it's actually 8. Not using diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 22ab8dddd0..8144a810ec 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -221,7 +221,7 @@ public: if (objclass->GetUISpecCount() == 0) continue; size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width + padding.width); } - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; resize->height = this->line_height; size->height = 5 * this->line_height; break; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 0bf8857efd..aca85ecd4d 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -224,11 +224,11 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int Dimension sprite_size = GetSpriteSize(sprite); if (v->cur_real_order_index == order_index) { /* Draw two arrows before the next real order. */ - DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2); - DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2); + DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2); + DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2); } else if (v->cur_implicit_order_index == order_index) { /* Draw one arrow before the next implicit order; the next real order will still get two arrows. */ - DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2); + DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2); } TextColour colour = TC_BLACK; @@ -805,7 +805,7 @@ public: { switch (widget) { case WID_O_ORDER_LIST: - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); size->height = 6 * resize->height + padding.height; break; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index ded9db9fe0..78251ecddd 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -969,7 +969,7 @@ private: public: BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE) { - this->coverage_height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; this->vscroll = nullptr; _railstation.newstations = newstation; @@ -1194,7 +1194,7 @@ public: d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name)); } size->width = std::max(size->width, d.width + padding.width); - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; size->height = 5 * this->line_height; resize->height = this->line_height; break; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 40be806900..7e7bd81b91 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1140,7 +1140,7 @@ private: public: BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE) { - this->coverage_height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; this->vscrollList = nullptr; this->vscrollMatrix = nullptr; this->roadStopType = rs; @@ -1349,7 +1349,7 @@ public: d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name)); } size->width = std::max(size->width, d.width + padding.width); - this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical(); + this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(); size->height = 5 * this->line_height; resize->height = this->line_height; break; diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index 99654c6c7f..576e679c4e 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -36,7 +36,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r) SetDParam(1, v->build_year); SetDParam(2, v->value); DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); if (v->HasArticulatedPart()) { CargoArray max_cargo{}; @@ -71,7 +71,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r) } DrawString(r.left, r.right, y, capacity, TC_BLUE); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; for (const Vehicle *u = v; u != nullptr; u = u->Next()) { if (u->cargo_cap == 0) continue; @@ -85,7 +85,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r) feeder_share += u->cargo.GetFeederShare(); } DrawString(r.left, r.right, y, str); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); } y += WidgetDimensions::scaled.vsep_normal; } else { @@ -93,7 +93,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r) SetDParam(1, v->cargo_cap); SetDParam(4, GetCargoSubtypeText(v)); DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; str = STR_VEHICLE_DETAILS_CARGO_EMPTY; if (v->cargo.StoredCount() > 0) { @@ -104,7 +104,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r) feeder_share += v->cargo.GetFeederShare(); } DrawString(r.left, r.right, y, str); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } /* Draw Transfer credits text */ diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 39cf1a00a1..ddad096fc3 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -106,7 +106,7 @@ struct ScriptListWindow : public Window { { if (widget != WID_SCRL_LIST) return; - this->line_height = FONT_HEIGHT_NORMAL + padding.height; + this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; resize->width = 1; resize->height = this->line_height; @@ -149,14 +149,14 @@ struct ScriptListWindow : public Window { Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect); SetDParamStr(0, selected_info->GetAuthor()); DrawString(tr, STR_AI_LIST_AUTHOR); - tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; SetDParam(0, selected_info->GetVersion()); DrawString(tr, STR_AI_LIST_VERSION); - tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; if (!selected_info->GetURL().empty()) { SetDParamStr(0, selected_info->GetURL()); DrawString(tr, STR_AI_LIST_URL); - tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } SetDParamStr(0, selected_info->GetDescription()); DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_WHITE); @@ -346,7 +346,7 @@ struct ScriptSettingsWindow : public Window { { if (widget != WID_SCRS_BACKGROUND) return; - this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height; + this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; resize->width = 1; resize->height = this->line_height; @@ -369,7 +369,7 @@ struct ScriptSettingsWindow : public Window { int y = r.top; int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; - int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) { const ScriptConfigItem &config_item = **it; int current_value = config->GetSetting((config_item).name); @@ -793,7 +793,7 @@ struct ScriptDebugWindow : public Window { void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_SCRD_LOG_PANEL) { - resize->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index ebbbb8ba24..5b23df1f81 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1350,7 +1350,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32_t)value != sd->max); } this->SetValueDParams(1, value); - DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sd->str, highlight ? TC_WHITE : TC_LIGHT_BLUE); + DrawString(text_left, text_right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, sd->str, highlight ? TC_WHITE : TC_LIGHT_BLUE); } /* == SettingsContainer methods == */ @@ -1673,7 +1673,7 @@ void SettingsPage::DrawSetting(GameSettings *, int left, int right, int y, bool) { bool rtl = _current_text_dir == TD_RTL; DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2); - DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title, TC_ORANGE); + DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, this->title, TC_ORANGE); } /** Construct settings tree */ @@ -2078,7 +2078,7 @@ struct GameSettingsWindow : Window { { switch (widget) { case WID_GS_OPTIONSPANEL: - resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + WidgetDimensions::scaled.vsep_normal; + resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal; resize->width = 1; size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); @@ -2094,7 +2094,7 @@ struct GameSettingsWindow : Window { SetDParam(0, setting_types[i]); size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width); } - size->height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + + size->height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width)); break; } @@ -2138,7 +2138,7 @@ struct GameSettingsWindow : Window { /* Draw the 'some search results are hidden' notice. */ if (this->warn_missing != WHR_NONE) { SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]); - DrawStringMultiLine(panel.WithHeight(this->warn_lines * FONT_HEIGHT_NORMAL), warn_str, TC_FROMSTRING, SA_CENTER); + DrawStringMultiLine(panel.WithHeight(this->warn_lines * GetCharacterHeight(FS_NORMAL)), warn_str, TC_FROMSTRING, SA_CENTER); } } @@ -2209,11 +2209,11 @@ struct GameSettingsWindow : Window { default: NOT_REACHED(); } DrawString(tr, STR_CONFIG_SETTING_TYPE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); this->last_clicked->SetValueDParams(0, sd->def); DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE); - tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; DrawStringMultiLine(tr, this->last_clicked->GetHelpText(), TC_WHITE); } diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index 7ff8ac20c8..fbc174fc8d 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -67,13 +67,13 @@ void DrawShipDetails(const Vehicle *v, const Rect &r) SetDParam(1, v->build_year); SetDParam(2, v->value); DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE); - y += FONT_HEIGHT_NORMAL; + y += GetCharacterHeight(FS_NORMAL); SetDParam(0, v->cargo_type); SetDParam(1, v->cargo_cap); SetDParam(4, GetCargoSubtypeText(v)); DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY; if (v->cargo.StoredCount() > 0) { @@ -83,7 +83,7 @@ void DrawShipDetails(const Vehicle *v, const Rect &r) str = STR_VEHICLE_DETAILS_CARGO_FROM; } DrawString(r.left, r.right, y, str); - y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; + y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; /* Draw Transfer credits text */ SetDParam(0, v->cargo.GetFeederShare()); diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 271894f91b..b52b1c3a92 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -197,7 +197,7 @@ struct SignListWindow : Window, SignList { switch (widget) { case WID_SIL_LIST: { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); - uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2; + uint text_offset_y = (this->resize.step_height - GetCharacterHeight(FS_NORMAL) + 1) / 2; /* No signs? */ if (this->vscroll->GetCount() == 0) { DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_STATION_LIST_NONE); @@ -269,7 +269,7 @@ struct SignListWindow : Window, SignList { case WID_SIL_LIST: { Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON); this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text. - resize->height = std::max(FONT_HEIGHT_NORMAL, spr_dim.height + 2); + resize->height = std::max(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2); Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height}; *size = maxdim(*size, d); break; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index ed9144e02c..d5fee861dc 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -714,7 +714,7 @@ protected: inline uint GetLegendHeight(uint num_columns) const { return WidgetDimensions::scaled.framerect.Vertical() + - this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL; + this->GetNumberRowsLegend(num_columns) * GetCharacterHeight(FS_SMALL); } /** @@ -994,7 +994,7 @@ protected: /* Check if the town sign is within bounds */ if (x + t->cache.sign.width_small > dpi->left && x < dpi->left + dpi->width && - y + FONT_HEIGHT_SMALL > dpi->top && + y + GetCharacterHeight(FS_SMALL) > dpi->top && y < dpi->top + dpi->height) { /* And draw it. */ SetDParam(0, t->index); @@ -1350,7 +1350,7 @@ protected: int GetPositionOnLegend(Point pt) { const NWidgetBase *wi = this->GetWidget(WID_SM_LEGEND); - uint line = (pt.y - wi->pos_y - WidgetDimensions::scaled.framerect.top) / FONT_HEIGHT_SMALL; + uint line = (pt.y - wi->pos_y - WidgetDimensions::scaled.framerect.top) / GetCharacterHeight(FS_SMALL); uint columns = this->GetNumberColumnsLegend(wi->current_x); uint number_of_rows = this->GetNumberRowsLegend(columns); if (line >= number_of_rows) return -1; @@ -1515,7 +1515,7 @@ public: } /* Width of the legend blob. */ - this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5; + this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 8 / 5; /* The width of a column is the minimum width of all texts + the size of the blob + some spacing */ this->column_width = min_width + WidgetDimensions::scaled.hsep_normal + this->legend_width + WidgetDimensions::scaled.framerect.Horizontal(); @@ -1553,7 +1553,7 @@ public: uint number_of_rows = this->GetNumberRowsLegend(columns); bool rtl = _current_text_dir == TD_RTL; uint i = 0; // Row counter for industry legend. - uint row_height = FONT_HEIGHT_SMALL; + uint row_height = GetCharacterHeight(FS_SMALL); int padding = ScaleGUITrad(1); Rect origin = r.WithWidth(this->column_width, rtl).Shrink(WidgetDimensions::scaled.framerect).WithHeight(row_height); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 2eac0f2980..88c05ffc01 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -407,7 +407,7 @@ public: } case WID_STL_LIST: - resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleGUITrad(3)); + resize->height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3)); size->height = padding.height + 5 * resize->height; /* Determine appropriate width for mini station rating graph */ @@ -466,7 +466,7 @@ public: SetDParam(0, st->index); SetDParam(1, st->facilities); - int x = DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION); + int x = DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_STATION_LIST_STATION); x += rtl ? -text_spacing : text_spacing; /* show cargo waiting and station ratings */ @@ -492,7 +492,7 @@ public: } if (this->vscroll->GetCount() == 0) { // company has no stations - DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_NONE); + DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_STATION_LIST_NONE); return; } break; @@ -506,7 +506,7 @@ public: br = br.Translate(cg_ofst, cg_ofst); GfxFillRect(br, cs->rating_colour); TextColour tc = GetContrastColour(cs->rating_colour); - DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cs->abbrev, tc, SA_HOR_CENTER, false, FS_SMALL); + DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cs->abbrev, tc, SA_HOR_CENTER, false, FS_SMALL); } break; } @@ -1385,13 +1385,13 @@ struct StationViewWindow : public Window { { switch (widget) { case WID_SV_WAITING: - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); size->height = 4 * resize->height + padding.height; this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width); break; case WID_SV_ACCEPT_RATING_LIST: - size->height = ((this->GetWidget(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * FONT_HEIGHT_NORMAL + padding.height; + size->height = ((this->GetWidget(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height; break; case WID_SV_CLOSE_AIRPORT: @@ -1763,7 +1763,7 @@ struct StationViewWindow : public Window { if (pos > -maxrows && pos <= 0) { StringID str = STR_EMPTY; - int y = r.top - pos * FONT_HEIGHT_NORMAL; + int y = r.top - pos * GetCharacterHeight(FS_NORMAL); SetDParam(0, cargo); SetDParam(1, cd->GetCount()); @@ -1836,7 +1836,7 @@ struct StationViewWindow : public Window { SetDParam(0, GetAcceptanceMask(st)); int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO); - return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL); + return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL)); } /** @@ -1857,7 +1857,7 @@ struct StationViewWindow : public Window { } DrawString(tr, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); for (const CargoSpec *cs : _sorted_standard_cargo_specs) { const GoodsEntry *ge = &st->goods[cs->Index()]; @@ -1869,9 +1869,9 @@ struct StationViewWindow : public Window { SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5)); SetDParam(3, ToPercent8(ge->rating)); DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } - return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL); + return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL)); } /** @@ -1939,7 +1939,7 @@ struct StationViewWindow : public Window { nwi->SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP); // Switch to ratings view. height_change = this->accepts_lines - this->rating_lines; } - this->ReInit(0, height_change * FONT_HEIGHT_NORMAL); + this->ReInit(0, height_change * GetCharacterHeight(FS_NORMAL)); break; } diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 34632838ae..9d8bc32e4d 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -112,7 +112,7 @@ struct StatusBarWindow : Window { void DrawWidget(const Rect &r, int widget) const override { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero); - tr.top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL); + tr.top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); switch (widget) { case WID_S_LEFT: /* Draw the date */ diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 5ceefed8e2..15cd7ac994 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -287,7 +287,7 @@ protected: int height = 0; /* Title lines */ - height += FONT_HEIGHT_NORMAL; // Date always use exactly one line. + height += GetCharacterHeight(FS_NORMAL); // Date always use exactly one line. SetDParamStr(0, !page->title.empty() ? page->title : this->selected_generic_title); height += GetStringHeight(STR_STORY_BOOK_TITLE, max_width); @@ -404,7 +404,7 @@ protected: StoryPage *page = this->GetSelPage(); if (page == nullptr) return; int max_width = GetAvailablePageContentWidth(); - int element_dist = FONT_HEIGHT_NORMAL; + int element_dist = GetCharacterHeight(FS_NORMAL); /* Make space for the header */ int main_y = GetHeadHeight(max_width) + element_dist; @@ -425,7 +425,7 @@ protected: if (fl == ElementFloat::None) { /* Verify available width */ - const int min_required_width = 10 * FONT_HEIGHT_NORMAL; + const int min_required_width = 10 * GetCharacterHeight(FS_NORMAL); int left_offset = (left_width == 0) ? 0 : (left_width + element_dist); int right_offset = (right_width == 0) ? 0 : (right_width + element_dist); if (left_offset + right_offset + min_required_width >= max_width) { @@ -596,7 +596,7 @@ public: { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SB_SCROLLBAR); - this->vscroll->SetStepSize(FONT_HEIGHT_NORMAL); + this->vscroll->SetStepSize(GetCharacterHeight(FS_NORMAL)); /* Initialize page sort. */ this->story_pages.SetSortFuncs(StoryBookWindow::page_sorter_funcs); @@ -694,7 +694,7 @@ public: /* Draw content (now coordinates given to Draw** are local to the new clipping region). */ fr = fr.Translate(-fr.left, -fr.top); - int line_height = FONT_HEIGHT_NORMAL; + int line_height = GetCharacterHeight(FS_NORMAL); const int scrollpos = this->vscroll->GetPosition(); int y_offset = -scrollpos; @@ -756,7 +756,7 @@ public: if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; Dimension d; - d.height = FONT_HEIGHT_NORMAL; + d.height = GetCharacterHeight(FS_NORMAL); d.width = 0; switch (widget) { diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index c45939944f..c55c9409b4 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -130,7 +130,7 @@ struct SubsidyListWindow : Window { if (widget != WID_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); d.height *= 5; d.width += WidgetDimensions::scaled.framerect.Horizontal(); @@ -151,7 +151,7 @@ struct SubsidyListWindow : Window { const int cap = this->vscroll->GetCapacity(); /* Section for drawing the offered subsidies */ - if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_TITLE); + if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_TITLE); pos++; uint num = 0; @@ -161,7 +161,7 @@ struct SubsidyListWindow : Window { /* Displays the two offered towns */ SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui); SetDParam(7, TimerGameCalendar::date - ymd.day + s->remaining * 32); - DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO); + DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO); } pos++; num++; @@ -169,13 +169,13 @@ struct SubsidyListWindow : Window { } if (num == 0) { - if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE); + if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_NONE); pos++; } /* Section for drawing the already granted subsidies */ pos++; - if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE); + if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_TITLE); pos++; num = 0; @@ -187,7 +187,7 @@ struct SubsidyListWindow : Window { SetDParam(8, TimerGameCalendar::date - ymd.day + s->remaining * 32); /* Displays the two connected stations */ - DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO); + DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO); } pos++; num++; @@ -195,7 +195,7 @@ struct SubsidyListWindow : Window { } if (num == 0) { - if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE); + if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_NONE); pos++; } } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index bf63a24dea..3f5319cb26 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -112,7 +112,7 @@ uint TextfileWindow::ReflowContent() int max_width = this->GetWidget(WID_TF_BACKGROUND)->current_x - WidgetDimensions::scaled.frametext.Horizontal(); for (auto &line : this->lines) { line.top = height; - height += GetStringHeight(line.text, max_width, FS_MONO) / FONT_HEIGHT_MONO; + height += GetStringHeight(line.text, max_width, FS_MONO) / GetCharacterHeight(FS_MONO); line.bottom = height; } } @@ -130,7 +130,7 @@ uint TextfileWindow::GetContentHeight() { switch (widget) { case WID_TF_BACKGROUND: - resize->height = FONT_HEIGHT_MONO; + resize->height = GetCharacterHeight(FS_MONO); size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible. size->width = std::max(200u, size->width); // At least 200 pixels wide. @@ -301,7 +301,7 @@ void TextfileWindow::CheckHyperlinkClick(Point pt) if (this->links.empty()) return; /* Which line was clicked. */ - const int clicked_row = this->GetRowFromWidget(pt.y, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.top, FONT_HEIGHT_MONO) + this->GetScrollbar(WID_TF_VSCROLLBAR)->GetPosition(); + const int clicked_row = this->GetRowFromWidget(pt.y, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.top, GetCharacterHeight(FS_MONO)) + this->GetScrollbar(WID_TF_VSCROLLBAR)->GetPosition(); size_t line_index; size_t subline; if (IsWidgetLowered(WID_TF_WRAPTEXT)) { @@ -311,7 +311,7 @@ void TextfileWindow::CheckHyperlinkClick(Point pt) subline = clicked_row - it->top; Debug(misc, 4, "TextfileWindow check hyperlink: clicked_row={}, line_index={}, line.top={}, subline={}", clicked_row, line_index, it->top, subline); } else { - line_index = clicked_row / FONT_HEIGHT_MONO; + line_index = clicked_row / GetCharacterHeight(FS_MONO); subline = 0; } @@ -560,7 +560,7 @@ void TextfileWindow::AfterLoadMarkdown() /* Draw content (now coordinates given to DrawString* are local to the new clipping region). */ fr = fr.Translate(-fr.left, -fr.top); - int line_height = FONT_HEIGHT_MONO; + int line_height = GetCharacterHeight(FS_MONO); int pos = this->vscroll->GetPosition(); int cap = this->vscroll->GetCapacity(); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index e8bd258288..c38b91f434 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -200,12 +200,12 @@ struct TimetableWindow : Window { case WID_VT_ARRIVAL_DEPARTURE_SELECTION: case WID_VT_TIMETABLE_PANEL: - resize->height = FONT_HEIGHT_NORMAL; + resize->height = GetCharacterHeight(FS_NORMAL); size->height = 8 * resize->height + padding.height; break; case WID_VT_SUMMARY_PANEL: - size->height = 2 * FONT_HEIGHT_NORMAL + padding.height; + size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; break; } } @@ -411,7 +411,7 @@ struct TimetableWindow : Window { } i++; - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } } @@ -470,7 +470,7 @@ struct TimetableWindow : Window { DrawString(tr.left, tr.right, tr.top, STR_TIMETABLE_DEPARTURE, i == selected ? TC_WHITE : TC_BLACK); } } - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } } @@ -488,7 +488,7 @@ struct TimetableWindow : Window { SetTimetableParams(0, 1, total_time); DrawString(tr, v->orders->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE); } - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); if (v->timetable_start != 0) { /* We are running towards the first station so we can start the diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 7dc909b671..ec85846a3f 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -149,7 +149,7 @@ public: uint Height() const override { - return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)FONT_HEIGHT_NORMAL); + return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)GetCharacterHeight(FS_NORMAL)); } void Draw(const Rect &r, bool sel, Colours) const override @@ -162,7 +162,7 @@ public: Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero); int icon_y = CenterBounds(r.top, r.bottom, icon_size.height); - int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL); + int text_y = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); int lock_y = CenterBounds(r.top, r.bottom, lock_size.height); DrawCompanyIcon(company, tr.WithWidth(this->icon_size.width, rtl).left, icon_y); @@ -2368,11 +2368,11 @@ struct ScenarioEditorToolbarWindow : Window { switch (widget) { case WID_TE_SPACER: { int height = r.Height(); - if (height > 2 * FONT_HEIGHT_NORMAL) { - DrawString(r.left, r.right, height / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER); + if (height > 2 * GetCharacterHeight(FS_NORMAL)) { + DrawString(r.left, r.right, height / 2 - GetCharacterHeight(FS_NORMAL), STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER); DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER); } else { - DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER); + DrawString(r.left, r.right, (height - GetCharacterHeight(FS_NORMAL)) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER); } break; } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 9b4e39c0ed..e91870af95 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -151,7 +151,7 @@ public: { Rect r = this->GetWidget(WID_TA_RATING_INFO)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect); - int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2; int icon_y_offset = (this->resize.step_height - this->icon_size.height) / 2; int exclusive_y_offset = (this->resize.step_height - this->exclusive_size.height) / 2; @@ -204,7 +204,7 @@ public: Rect r = this->GetWidget(WID_TA_COMMAND_LIST)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect); DrawString(r, STR_LOCAL_AUTHORITY_ACTIONS_TITLE); - r.top += FONT_HEIGHT_NORMAL; + r.top += GetCharacterHeight(FS_NORMAL); /* Draw list of actions */ for (int i = 0; i < TACT_COUNT; i++) { @@ -217,7 +217,7 @@ public: if (this->sel_index == i) action_colour = TC_WHITE; DrawString(r, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, action_colour); - r.top += FONT_HEIGHT_NORMAL; + r.top += GetCharacterHeight(FS_NORMAL); } } @@ -260,7 +260,7 @@ public: } case WID_TA_COMMAND_LIST: - size->height = (TACT_COUNT + 1) * FONT_HEIGHT_NORMAL + padding.height; + size->height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height; size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width; for (uint i = 0; i < TACT_COUNT; i++ ) { size->width = std::max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width); @@ -269,7 +269,7 @@ public: break; case WID_TA_RATING_INFO: - resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)FONT_HEIGHT_NORMAL}); + resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)}); size->height = 9 * resize->height + padding.height; break; } @@ -291,7 +291,7 @@ public: } case WID_TA_COMMAND_LIST: { - int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL) - 1; + int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, GetCharacterHeight(FS_NORMAL)) - 1; y = GetNthSetBit(y); if (y >= 0) { @@ -392,19 +392,19 @@ public: SetDParam(0, this->town->cache.population); SetDParam(1, this->town->cache.num_houses); DrawString(tr, STR_TOWN_VIEW_POPULATION_HOUSES); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, 1 << CT_PASSENGERS); SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act); SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max); DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); SetDParam(0, 1 << CT_MAIL); SetDParam(1, this->town->supplied[CT_MAIL].old_act); SetDParam(2, this->town->supplied[CT_MAIL].old_max); DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); bool first = true; for (int i = TE_BEGIN; i < TE_END; i++) { @@ -414,7 +414,7 @@ public: if (first) { DrawString(tr, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); first = false; } @@ -449,16 +449,16 @@ public: SetDParam(3, this->town->goal[i]); } DrawString(tr.Indent(20, rtl), string); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } if (HasBit(this->town->flags, TOWN_IS_GROWING)) { SetDParam(0, RoundDivSU(this->town->growth_rate + 1, Ticks::DAY_TICKS)); DrawString(tr, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } else { DrawString(tr, STR_TOWN_VIEW_TOWN_GROW_STOPPED); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } /* only show the town noise, if the noise option is activated. */ @@ -466,7 +466,7 @@ public: SetDParam(0, this->town->noise_reached); SetDParam(1, this->town->MaxTownNoise()); DrawString(tr, STR_TOWN_VIEW_NOISE_IN_TOWN); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); } if (!this->town->text.empty()) { @@ -525,7 +525,7 @@ public: */ uint GetDesiredInfoHeight(int width) const { - uint aimed_height = 3 * FONT_HEIGHT_NORMAL; + uint aimed_height = 3 * GetCharacterHeight(FS_NORMAL); bool first = true; for (int i = TE_BEGIN; i < TE_END; i++) { @@ -534,14 +534,14 @@ public: if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue; if (first) { - aimed_height += FONT_HEIGHT_NORMAL; + aimed_height += GetCharacterHeight(FS_NORMAL); first = false; } - aimed_height += FONT_HEIGHT_NORMAL; + aimed_height += GetCharacterHeight(FS_NORMAL); } - aimed_height += FONT_HEIGHT_NORMAL; + aimed_height += GetCharacterHeight(FS_NORMAL); - if (_settings_game.economy.station_noise_level) aimed_height += FONT_HEIGHT_NORMAL; + if (_settings_game.economy.station_noise_level) aimed_height += GetCharacterHeight(FS_NORMAL); if (!this->town->text.empty()) { SetDParamStr(0, this->town->text); @@ -850,7 +850,7 @@ public: SetDParam(0, t->index); SetDParam(1, t->cache.population); - DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t)); + DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2, GetTownString(t)); tr.top += this->resize.step_height; if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 34a6f6d370..ed7bf46b19 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -354,7 +354,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t v bool rtl = _current_text_dir == TD_RTL; int line_height = r.Height(); int sprite_y_offset = line_height / 2; - int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2; + int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2; /* draw the first 3 details tabs */ if (det_tab != TDW_TAB_TOTALS) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index c581a9ce1e..3a9ddbdc8a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -597,12 +597,12 @@ static void DrawVehicleRefitWindow(const RefitOptions &refits, const RefitOption if (has_subtypes) { if (refit.subtype != UINT8_MAX) { /* Draw tree lines */ - int ycenter = tr.top + FONT_HEIGHT_NORMAL / 2; + int ycenter = tr.top + GetCharacterHeight(FS_NORMAL) / 2; GfxDrawLine(iconcenter, tr.top - WidgetDimensions::scaled.matrix.top, iconcenter, (&refit == &pair.second.back()) ? ycenter : tr.top - WidgetDimensions::scaled.matrix.top + delta - 1, linecolour); GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour); } else { /* Draw expand/collapse icon */ - DrawSprite((sel != nullptr && sel->cargo == refit.cargo) ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (FONT_HEIGHT_NORMAL - iconheight) / 2); + DrawSprite((sel != nullptr && sel->cargo == refit.cargo) ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (GetCharacterHeight(FS_NORMAL) - iconheight) / 2); } } @@ -857,7 +857,7 @@ struct RefitWindow : public Window { { switch (widget) { case WID_VR_MATRIX: - resize->height = FONT_HEIGHT_NORMAL + padding.height; + resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; size->height = resize->height * 8; break; @@ -1558,7 +1558,7 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, uin SetDParam(0, order->GetDestination()); DrawString(left + l_offset, right - r_offset, y, STR_STATION_NAME, TC_BLACK, SA_LEFT, false, FS_SMALL); - y += FONT_HEIGHT_SMALL; + y += GetCharacterHeight(FS_SMALL); if (++i == 4) break; } @@ -1583,7 +1583,7 @@ static void DrawSmallOrderList(const Order *order, int left, int right, int y, u SetDParam(0, order->GetDestination()); DrawString(left + l_offset, right - r_offset, y, STR_STATION_NAME, TC_BLACK, SA_LEFT, false, FS_SMALL); - y += FONT_HEIGHT_SMALL; + y += GetCharacterHeight(FS_SMALL); if (++i == 4) break; } order = order->next; @@ -1617,9 +1617,9 @@ void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi uint GetVehicleListHeight(VehicleType type, uint divisor) { /* Name + vehicle + profit */ - uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * FONT_HEIGHT_SMALL + WidgetDimensions::scaled.matrix.Vertical(); + uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.matrix.Vertical(); /* Drawing of the 4 small orders + profit*/ - if (type >= VEH_SHIP) base = std::max(base, 5U * FONT_HEIGHT_SMALL + WidgetDimensions::scaled.matrix.Vertical()); + if (type >= VEH_SHIP) base = std::max(base, 5U * GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.matrix.Vertical()); if (divisor == 1) return base; @@ -1658,16 +1658,16 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int SetDParam(0, vehgroup.GetDisplayProfitThisYear()); SetDParam(1, vehgroup.GetDisplayProfitLastYear()); - DrawString(tr.left, tr.right, ir.bottom - FONT_HEIGHT_SMALL - WidgetDimensions::scaled.framerect.bottom, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR); + DrawString(tr.left, tr.right, ir.bottom - GetCharacterHeight(FS_SMALL) - WidgetDimensions::scaled.framerect.bottom, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR); - DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal); + DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, ir.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal); switch (this->grouping) { case GB_NONE: { const Vehicle *v = vehgroup.GetSingleVehicle(); if (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) { - DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + profit.height); + DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, ir.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + profit.height); } DrawVehicleImage(v, {image_left, ir.top, image_right, ir.bottom}, selected_vehicle, EIT_IN_LIST, 0); @@ -2341,13 +2341,13 @@ struct VehicleDetailsWindow : Window { uint desired_height; if (v->HasArticulatedPart()) { /* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */ - desired_height = ScaleGUITrad(15) + 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2; + desired_height = ScaleGUITrad(15) + 3 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2; /* Add space for the cargo amount for each part. */ for (const Vehicle *u = v; u != nullptr; u = u->Next()) { - if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL; + if (u->cargo_cap != 0) desired_height += GetCharacterHeight(FS_NORMAL); } } else { - desired_height = 4 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2; + desired_height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2; } return desired_height; } @@ -2357,7 +2357,7 @@ struct VehicleDetailsWindow : Window { switch (widget) { case WID_VD_TOP_DETAILS: { Dimension dim = { 0, 0 }; - size->height = 4 * FONT_HEIGHT_NORMAL + padding.height; + size->height = 4 * GetCharacterHeight(FS_NORMAL) + padding.height; for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX); static const StringID info_strings[] = { @@ -2384,11 +2384,11 @@ struct VehicleDetailsWindow : Window { break; case VEH_SHIP: - size->height = 4 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; + size->height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; break; case VEH_AIRCRAFT: - size->height = 5 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; + size->height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; break; default: @@ -2398,7 +2398,7 @@ struct VehicleDetailsWindow : Window { } case WID_VD_MATRIX: - resize->height = std::max(ScaleGUITrad(14), FONT_HEIGHT_NORMAL + padding.height); + resize->height = std::max(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height); size->height = 4 * resize->height; break; @@ -2421,7 +2421,7 @@ struct VehicleDetailsWindow : Window { GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width, GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width ) + padding.width; - size->height = FONT_HEIGHT_NORMAL + padding.height; + size->height = GetCharacterHeight(FS_NORMAL) + padding.height; break; } } @@ -2478,7 +2478,7 @@ struct VehicleDetailsWindow : Window { SetDParam(2, TimerGameCalendar::DateToYear(v->max_age)); SetDParam(3, v->GetDisplayRunningCost()); DrawString(tr, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); /* Draw max speed */ StringID string; @@ -2510,7 +2510,7 @@ struct VehicleDetailsWindow : Window { } } DrawString(tr, string); - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); /* Draw profit */ SetDParam(0, v->GetDisplayProfitThisYear()); @@ -2521,7 +2521,7 @@ struct VehicleDetailsWindow : Window { } else { DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR); } - tr.top += FONT_HEIGHT_NORMAL; + tr.top += GetCharacterHeight(FS_NORMAL); /* Draw breakdown & reliability */ SetDParam(0, ToPercent16(v->reliability)); @@ -2559,7 +2559,7 @@ struct VehicleDetailsWindow : Window { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); SetDParam(0, v->GetServiceInterval()); SetDParam(1, v->date_of_last_service); - DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), + DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS); break; } @@ -2917,7 +2917,7 @@ public: const Vehicle *v = Vehicle::Get(this->window_number); switch (widget) { case WID_VV_START_STOP: - size->height = std::max({size->height, (uint)FONT_HEIGHT_NORMAL, GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height; + size->height = std::max({size->height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height; break; case WID_VV_FORCE_PROCEED: @@ -3070,7 +3070,7 @@ public: SpriteID image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING; DrawSpriteIgnorePadding(image, PAL_NONE, tr.WithWidth(icon_width, rtl), false, SA_CENTER); tr = tr.Indent(icon_width + WidgetDimensions::scaled.imgbtn.Horizontal(), rtl); - DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), str, text_colour, SA_HOR_CENTER); + DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), str, text_colour, SA_HOR_CENTER); } void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override diff --git a/src/viewport.cpp b/src/viewport.cpp index caa33662a8..e0af8f5f50 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1303,7 +1303,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie int right = left + dpi->width; int bottom = top + dpi->height; - int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom); + int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom); int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom); if (bottom < sign->top || @@ -1328,7 +1328,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie static Rect ExpandRectWithViewportSignMargins(Rect r, ZoomLevel zoom) { /* Pessimistically always use normal font, but also assume small font is never larger in either dimension */ - const int fh = FONT_HEIGHT_NORMAL; + const int fh = GetCharacterHeight(FS_NORMAL); const int max_tw = _viewport_sign_maxwidth / 2 + 1; const int expand_y = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + fh + WidgetDimensions::scaled.fullbevel.bottom, zoom); const int expand_x = ScaleByZoom(WidgetDimensions::scaled.fullbevel.left + max_tw + WidgetDimensions::scaled.fullbevel.right, zoom); @@ -1484,7 +1484,7 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const zoomlevels[zoom].left = this->center - ScaleByZoom(this->width_normal / 2 + 1, zoom); zoomlevels[zoom].top = this->top - ScaleByZoom(1, zoom); zoomlevels[zoom].right = this->center + ScaleByZoom(this->width_normal / 2 + 1, zoom); - zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom); + zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom); } for (const Window *w : Window::Iterate()) { @@ -1698,7 +1698,7 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector * int w = GB(ss.width, 0, 15); int x = UnScaleByZoom(ss.x, zoom); int y = UnScaleByZoom(ss.y, zoom); - int h = WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom; + int h = WidgetDimensions::scaled.fullbevel.top + (small ? GetCharacterHeight(FS_SMALL) : GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.fullbevel.bottom; if (ss.colour != INVALID_COLOUR) { if (IsTransparencySet(TO_SIGNS) && ss.string_id != STR_WHITE_SIGN) { @@ -2131,7 +2131,7 @@ static bool CheckClickOnViewportSign(const Viewport *vp, int x, int y, const Vie { bool small = (vp->zoom >= ZOOM_LVL_OUT_16X); int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp->zoom); - int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom); + int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? GetCharacterHeight(FS_SMALL) : GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom); return y >= sign->top && y < sign->top + sign_height && x >= sign->center - sign_half_width && x < sign->center + sign_half_width; diff --git a/src/widget.cpp b/src/widget.cpp index 03eb3ff636..d5f35d6d21 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -693,7 +693,7 @@ static inline void DrawFrame(const Rect &r, Colours colour, TextColour text_colo /* If the frame has text, adjust the top bar to fit half-way through */ Rect inner = r.Shrink(ScaleGUITrad(1)); - if (str != STR_NULL) inner.top = r.top + FONT_HEIGHT_NORMAL / 2; + if (str != STR_NULL) inner.top = r.top + GetCharacterHeight(FS_NORMAL) / 2; Rect outer = inner.Expand(WidgetDimensions::scaled.bevel); Rect inside = inner.Shrink(WidgetDimensions::scaled.bevel); @@ -851,14 +851,14 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke DrawImageButtons(r.WithWidth(dd_width, true), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER); if (str != STR_NULL) { int o = clicked_button ? WidgetDimensions::scaled.pressed : 0; - DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left + o, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL) + o, str, TC_BLACK, align); + DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left + o, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align); } } else { DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE); DrawImageButtons(r.WithWidth(dd_width, false), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER); if (str != STR_NULL) { int o = clicked_button ? WidgetDimensions::scaled.pressed : 0; - DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left + o, r.right - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL) + o, str, TC_BLACK, align); + DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left + o, r.right - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align); } } } @@ -1166,7 +1166,7 @@ void NWidgetResizeBase::SetResize(uint resize_x, uint resize_y) bool NWidgetResizeBase::UpdateMultilineWidgetSize(const std::string &str, int max_lines) { int y = GetStringHeight(str, this->current_x); - if (y > max_lines * FONT_HEIGHT_NORMAL) { + if (y > max_lines * GetCharacterHeight(FS_NORMAL)) { /* Text at the current width is too tall, so try to guess a better width. */ Dimension d = GetStringBoundingBox(str); d.height *= max_lines; @@ -2293,7 +2293,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array) if (this->type == WWT_FRAME) { /* Account for the size of the frame's text if that exists */ this->child->padding = WidgetDimensions::scaled.frametext; - this->child->padding.top = std::max(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.top / 2 : 0); + this->child->padding.top = std::max(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.top / 2 : 0); this->smallest_x += this->child->padding.Horizontal(); this->smallest_y += this->child->padding.Vertical(); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index a36dc63bad..b7b423d12d 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -80,7 +80,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin uint DropDownListIconItem::Height() const { - return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL); + return std::max(this->dim.height, (uint)GetCharacterHeight(FS_NORMAL)); } uint DropDownListIconItem::Width() const @@ -94,7 +94,7 @@ void DropDownListIconItem::Draw(const Rect &r, bool sel, Colours) const Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext); Rect tr = ir.Indent(this->dim.width + WidgetDimensions::scaled.hsep_normal, rtl); DrawSprite(this->sprite, this->pal, ir.WithWidth(this->dim.width, rtl).left, CenterBounds(r.top, r.bottom, this->sprite_y)); - DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK); + DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), this->String(), sel ? TC_WHITE : TC_BLACK); } void DropDownListIconItem::SetDimension(Dimension d) diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index 12992f2168..3c045bd50e 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -27,7 +27,7 @@ public: virtual ~DropDownListItem() = default; virtual bool Selectable() const { return false; } - virtual uint Height() const { return FONT_HEIGHT_NORMAL; } + virtual uint Height() const { return GetCharacterHeight(FS_NORMAL); } virtual uint Width() const { return 0; } virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const; }; diff --git a/src/widgets/slider.cpp b/src/widgets/slider.cpp index f7678908d3..29fc1138aa 100644 --- a/src/widgets/slider.cpp +++ b/src/widgets/slider.cpp @@ -29,7 +29,7 @@ static const int SLIDER_WIDTH = 3; void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map &labels) { /* Allow space for labels. We assume they are in the small font. */ - if (!labels.empty()) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal; + if (!labels.empty()) r.bottom -= GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.hsep_normal; max_value -= min_value; diff --git a/src/window.cpp b/src/window.cpp index 2047a6efd7..b05615ab2c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1612,7 +1612,7 @@ static Point GetAutoPlacePosition(int width, int height) */ int left = rtl ? _screen.width - width : 0, top = toolbar_y; int offset_x = rtl ? -(int)NWidgetLeaf::closebox_dimension.width : (int)NWidgetLeaf::closebox_dimension.width; - int offset_y = std::max(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical()); + int offset_y = std::max(NWidgetLeaf::closebox_dimension.height, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.captiontext.Vertical()); restart: for (const Window *w : Window::Iterate()) { @@ -1678,7 +1678,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i * - Y position: closebox of parent + closebox of child + statusbar * - X position: closebox on left/right, resizebox on right/left (depending on ltr/rtl) */ - int indent_y = std::max(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical()); + int indent_y = std::max(NWidgetLeaf::closebox_dimension.height, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.captiontext.Vertical()); if (w->top + 3 * indent_y < _screen.height) { pt.y = w->top + indent_y; int indent_close = NWidgetLeaf::closebox_dimension.width;