Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

You can build *Passes* using GNOME Builder: import the project and press the Play button.

<details>
<summary>Dependencies</summary>
<br>

Passes requires `flatpak-builder` to be installed alongside gnome-builder
</details>

## Install

The recommended way of installing *Passes* is via Flatpak:
Expand Down
21 changes: 18 additions & 3 deletions src/formats/pkpass/pkpass_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ def plot(self, snapshot):

def _plot_header(self):
header_height = 32
header_width = self.pass_width() - (self.pass_margin() * 2)

# Draw the logo if it exists
if self._logo_texture:
logo_scale = header_height / self._logo_texture.get_height()
logo_width = self._logo_texture.get_width() * logo_scale
logo_height_scale = header_height / self._logo_texture.get_height()
logo_width_scale = (header_width / 2) / self._logo_texture.get_width()
logo_scale = min(logo_height_scale, logo_width_scale)
scaled_logo_width = self._logo_texture.get_width() * logo_scale
scaled_logo_height = self._logo_texture.get_height() * logo_scale

rectangle = Graphene.Rect()
rectangle.init(self.pass_margin(), self.pass_margin(), logo_width, header_height)
rectangle.init(self.pass_margin(), self.pass_margin(), scaled_logo_width, scaled_logo_height)
self._snapshot.append_texture(self._logo_texture, rectangle)

point = Graphene.Point()
Expand Down Expand Up @@ -229,7 +233,18 @@ def _plot_primary_fields(self):
value_font = PassFont.biggest_value,
alignment = Pango.Alignment.RIGHT)

# Check if font size needs to be reduced
if origin_field.get_value_width() > (max_row_width / 2) or destination_field.get_value_width() > (max_row_width / 2):
origin_field.set_value_font(PassFont.big_value)
destination_field.set_value_font(PassFont.big_value)

if origin_field.get_value_width() > (max_row_width / 2) or destination_field.get_value_width() > (max_row_width / 2):
origin_field.set_value_font(PassFont.value)
destination_field.set_value_font(PassFont.value)

# Set final widths
destination_field.set_width(self.pass_width() - 2 * self.pass_margin())
origin_field.set_width(max_row_width / 2)
self._snapshot.save()

point = Graphene.Point()
Expand Down
6 changes: 6 additions & 0 deletions src/view/pass_viewer/pass_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def get_height(self):

def get_width(self):
return self.__label.get_width() / Pango.SCALE

def get_value_width(self):
return self.__value.get_pixel_size().width

def set_value_font(self, font):
self.__value.set_font_description(font)

def set_alignment(self, alignment):
self.__label.set_alignment(alignment)
Expand Down