mirror of
https://github.com/jankammerath/BogusMips.git
synced 2026-11-07 10:15:59 -10:00
Add LICENSE.md for font files including Hack and Bitstream Vera licenses
This commit introduces a new LICENSE.md file in the media/fonts directory. It includes the MIT License for the Hack project and the Bitstream Vera License for the Bitstream Vera Sans Mono font, along with public domain information for the DejaVu project. This ensures proper attribution and legal compliance for the use of these fonts.
This commit is contained in:
1 parent
23f7b8db76
commit
68832219cd
9 files changed
+271
-39
No files matched your search
@@ -19,6 +19,8 @@ BogusMips is written in Rust and allows performing analyses on how far your Andr
|
||||
|
||||
All parsers (ZIP, DEX, smali disassembler, binary XML) are implemented in this repository. They follow Android's behaviour rather than the specs, so tricks that break other tools still open. Examples: malformed extra fields, fake encryption flags, CRC mismatches, and bogus compression methods. Such tricks are reported as warnings.
|
||||
|
||||
The UI uses the [Hack](https://github.com/source-foundry/Hack) font, which is embedded in the binary (`media/fonts`, see its [license](media/fonts/LICENSE.md)).
|
||||
|
||||
## Building & running
|
||||
|
||||
Requires Rust 1.85 or newer.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
||||
The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License
|
||||
|
||||
The work in the DejaVu project was committed to the public domain.
|
||||
|
||||
Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera"
|
||||
|
||||
### MIT License
|
||||
|
||||
Copyright (c) 2018 Source Foundry Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
### BITSTREAM VERA LICENSE
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.
|
||||
+7
-1
@@ -43,6 +43,7 @@ impl BogusMipsApp {
|
||||
}
|
||||
|
||||
pub fn with_context(ctx: &egui::Context, initial_file: Option<PathBuf>) -> Self {
|
||||
theme::install_fonts(ctx);
|
||||
theme::apply_dark(ctx);
|
||||
egui_extras::install_image_loaders(ctx);
|
||||
Self {
|
||||
@@ -296,7 +297,12 @@ impl BogusMipsApp {
|
||||
return;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
ui.strong("File information");
|
||||
ui.label(
|
||||
RichText::new("FILE INFORMATION")
|
||||
.small()
|
||||
.family(theme::bold_family())
|
||||
.color(ui.visuals().weak_text_color()),
|
||||
);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if ui
|
||||
.add(egui::Button::new("»").frame(false))
|
||||
|
||||
+113
-9
@@ -64,43 +64,73 @@ pub fn show(ui: &mut egui::Ui, inspection: &Inspection, mode: &mut ViewMode) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows `count` virtualized monospace rows. Each row has a gutter (line
|
||||
/// number / offset) that sticks to the left edge while the content scrolls
|
||||
/// horizontally underneath it.
|
||||
fn monospace_rows(
|
||||
ui: &mut egui::Ui,
|
||||
id: egui::Id,
|
||||
count: usize,
|
||||
mut row: impl FnMut(usize, &egui::FontId) -> LayoutJob,
|
||||
gutter_chars: usize,
|
||||
mut row: impl FnMut(usize, &egui::FontId) -> (String, LayoutJob),
|
||||
) {
|
||||
let font = TextStyle::Monospace.resolve(ui.style());
|
||||
let row_height = ui.fonts(|f| f.row_height(&font));
|
||||
let char_width = ui.fonts(|f| f.glyph_width(&font, '0'));
|
||||
let gutter_width = gutter_chars as f32 * char_width + 2.0 * GUTTER_PADDING;
|
||||
ui.scope(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
ui.spacing_mut().item_spacing = egui::vec2(0.0, 0.0);
|
||||
ScrollArea::both().id_salt(id).auto_shrink(false).show_rows(
|
||||
ui,
|
||||
row_height,
|
||||
count,
|
||||
|ui, range| {
|
||||
let viewport_left = ui.clip_rect().left();
|
||||
let background = ui.visuals().panel_fill;
|
||||
for i in range {
|
||||
ui.add(egui::Label::new(row(i, &font)).extend());
|
||||
let (gutter, job) = row(i, &font);
|
||||
let line = ui
|
||||
.horizontal(|ui| {
|
||||
ui.add_space(gutter_width);
|
||||
ui.add(egui::Label::new(job).extend());
|
||||
})
|
||||
.response
|
||||
.rect;
|
||||
// Painted after the text, so scrolled text slides under it.
|
||||
let rect = egui::Rect::from_min_size(
|
||||
egui::pos2(viewport_left, line.top()),
|
||||
egui::vec2(gutter_width, line.height().max(row_height)),
|
||||
);
|
||||
let painter = ui.painter();
|
||||
painter.rect_filled(rect, 0.0, background);
|
||||
painter.text(
|
||||
egui::pos2(rect.right() - GUTTER_PADDING, rect.top()),
|
||||
egui::Align2::RIGHT_TOP,
|
||||
gutter,
|
||||
font.clone(),
|
||||
GUTTER,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const GUTTER_PADDING: f32 = 8.0;
|
||||
|
||||
fn text_view(ui: &mut egui::Ui, id: egui::Id, lines: &[String], syntax: Syntax) {
|
||||
let digits = lines.len().max(1).to_string().len();
|
||||
monospace_rows(ui, id, lines.len(), |i, font| {
|
||||
monospace_rows(ui, id, lines.len(), digits, |i, font| {
|
||||
let mut job = LayoutJob::default();
|
||||
append(&mut job, &format!("{:>digits$} ", i + 1), GUTTER, font);
|
||||
highlight_into(&mut job, &lines[i], syntax, font);
|
||||
job
|
||||
((i + 1).to_string(), job)
|
||||
});
|
||||
}
|
||||
|
||||
fn hex_view(ui: &mut egui::Ui, id: egui::Id, data: &[u8]) {
|
||||
const ASCII: egui::Color32 = egui::Color32::from_rgb(0xce, 0x91, 0x78);
|
||||
let rows = data.len().div_ceil(16);
|
||||
monospace_rows(ui, id.with("hex"), rows, |row, font| {
|
||||
monospace_rows(ui, id.with("hex"), rows, 8, |row, font| {
|
||||
let start = row * 16;
|
||||
let chunk = &data[start..(start + 16).min(data.len())];
|
||||
let mut hex = String::with_capacity(16 * 3 + 1);
|
||||
@@ -121,9 +151,83 @@ fn hex_view(ui: &mut egui::Ui, id: egui::Id, data: &[u8]) {
|
||||
})
|
||||
.collect();
|
||||
let mut job = LayoutJob::default();
|
||||
append(&mut job, &format!("{start:08x} "), GUTTER, font);
|
||||
append(&mut job, &format!("{hex:<50}"), TEXT, font);
|
||||
append(&mut job, &ascii, ASCII, font);
|
||||
job
|
||||
(format!("{start:08x}"), job)
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::inspect::{Content, Inspection};
|
||||
|
||||
fn texts(output: &egui::FullOutput) -> Vec<(egui::Pos2, String)> {
|
||||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.filter_map(|c| match &c.shape {
|
||||
egui::Shape::Text(t) => Some((t.pos, t.galley.text().to_owned())),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn line_numbers_stick_while_scrolling_horizontally() {
|
||||
let ctx = egui::Context::default();
|
||||
crate::ui::theme::install_fonts(&ctx);
|
||||
let inspection = Inspection {
|
||||
node: 0,
|
||||
title: "x".into(),
|
||||
content: Content::Text {
|
||||
lines: vec![format!("first {}", "x".repeat(2000)), "second".into()],
|
||||
syntax: Syntax::Plain,
|
||||
},
|
||||
raw: None,
|
||||
sections: Vec::new(),
|
||||
};
|
||||
let mut mode = ViewMode::Preview;
|
||||
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0));
|
||||
let mut frame = |events: Vec<egui::Event>| {
|
||||
let input = egui::RawInput {
|
||||
screen_rect: Some(screen),
|
||||
events,
|
||||
..Default::default()
|
||||
};
|
||||
let output = ctx.run(input, |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| show(ui, &inspection, &mut mode));
|
||||
});
|
||||
texts(&output)
|
||||
};
|
||||
let find = |texts: &[(egui::Pos2, String)], pred: &dyn Fn(&str) -> bool| {
|
||||
texts
|
||||
.iter()
|
||||
.find(|(_, t)| pred(t))
|
||||
.map(|(p, _)| *p)
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let before = frame(vec![]);
|
||||
let number = find(&before, &|t| t == "1");
|
||||
let code = find(&before, &|t| t.starts_with("first"));
|
||||
let pointer = egui::pos2(400.0, 300.0);
|
||||
frame(vec![egui::Event::PointerMoved(pointer)]);
|
||||
for _ in 0..5 {
|
||||
frame(vec![egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: egui::vec2(-200.0, 0.0),
|
||||
modifiers: Default::default(),
|
||||
}]);
|
||||
}
|
||||
let after = frame(vec![]);
|
||||
let number_after = find(&after, &|t| t == "1");
|
||||
let code_after = find(&after, &|t| t.starts_with("first"));
|
||||
assert!(
|
||||
code_after.x < code.x - 100.0,
|
||||
"content did not scroll: {code:?} -> {code_after:?}"
|
||||
);
|
||||
assert_eq!(number, number_after, "line number moved");
|
||||
assert!(number.x < code.x);
|
||||
}
|
||||
}
|
||||
+23
-21
@@ -17,28 +17,30 @@ pub fn show(ui: &mut egui::Ui, inspection: Option<&Inspection>) {
|
||||
return;
|
||||
};
|
||||
for (i, section) in inspection.sections.iter().enumerate() {
|
||||
egui::CollapsingHeader::new(RichText::new(§ion.title).strong())
|
||||
.id_salt(("info_section", i, §ion.title))
|
||||
.default_open(true)
|
||||
.show(ui, |ui| {
|
||||
for (key, value) in §ion.rows {
|
||||
if !key.is_empty() {
|
||||
ui.label(
|
||||
RichText::new(key)
|
||||
.small()
|
||||
.color(ui.visuals().weak_text_color()),
|
||||
);
|
||||
}
|
||||
let monospace = key.contains("SHA") || key == "Signature";
|
||||
let text = if monospace {
|
||||
RichText::new(value).monospace()
|
||||
} else {
|
||||
RichText::new(value)
|
||||
};
|
||||
ui.add(egui::Label::new(text).wrap());
|
||||
ui.add_space(4.0);
|
||||
egui::CollapsingHeader::new(
|
||||
RichText::new(§ion.title).family(super::theme::bold_family()),
|
||||
)
|
||||
.id_salt(("info_section", i, §ion.title))
|
||||
.default_open(true)
|
||||
.show(ui, |ui| {
|
||||
for (key, value) in §ion.rows {
|
||||
if !key.is_empty() {
|
||||
ui.label(
|
||||
RichText::new(key)
|
||||
.small()
|
||||
.color(ui.visuals().weak_text_color()),
|
||||
);
|
||||
}
|
||||
});
|
||||
let monospace = key.contains("SHA") || key == "Signature";
|
||||
let text = if monospace {
|
||||
RichText::new(value).monospace()
|
||||
} else {
|
||||
RichText::new(value)
|
||||
};
|
||||
ui.add(egui::Label::new(text).wrap());
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
});
|
||||
|
||||
+78
-1
@@ -1,9 +1,57 @@
|
||||
use eframe::egui::{self, Color32};
|
||||
use std::sync::Arc;
|
||||
|
||||
use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, FontId};
|
||||
|
||||
/// Pitch black window and panel background.
|
||||
pub const BACKGROUND: Color32 = Color32::BLACK;
|
||||
pub const TEXT: Color32 = Color32::from_rgb(0xd4, 0xd4, 0xd4);
|
||||
|
||||
const HACK_REGULAR: &[u8] = include_bytes!("../../media/fonts/Hack-Regular.ttf");
|
||||
const HACK_BOLD: &[u8] = include_bytes!("../../media/fonts/Hack-Bold.ttf");
|
||||
const BOLD_FAMILY: &str = "Hack Bold";
|
||||
|
||||
/// Installs the bundled Hack font for all text. egui's default fonts stay
|
||||
/// as fallbacks for glyphs Hack lacks (e.g. the emoji used as tree icons).
|
||||
pub fn install_fonts(ctx: &egui::Context) {
|
||||
let mut fonts = FontDefinitions::default();
|
||||
fonts.font_data.insert(
|
||||
"Hack".to_owned(),
|
||||
Arc::new(FontData::from_static(HACK_REGULAR)),
|
||||
);
|
||||
fonts.font_data.insert(
|
||||
"Hack-Bold".to_owned(),
|
||||
Arc::new(FontData::from_static(HACK_BOLD)),
|
||||
);
|
||||
|
||||
let fallbacks = fonts
|
||||
.families
|
||||
.get(&FontFamily::Proportional)
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
for family in [FontFamily::Proportional, FontFamily::Monospace] {
|
||||
fonts
|
||||
.families
|
||||
.entry(family)
|
||||
.or_default()
|
||||
.insert(0, "Hack".to_owned());
|
||||
}
|
||||
let mut bold = vec!["Hack-Bold".to_owned()];
|
||||
bold.extend(fallbacks);
|
||||
fonts
|
||||
.families
|
||||
.insert(FontFamily::Name(BOLD_FAMILY.into()), bold);
|
||||
ctx.set_fonts(fonts);
|
||||
}
|
||||
|
||||
/// The bundled bold face, for headings.
|
||||
pub fn bold_family() -> FontFamily {
|
||||
FontFamily::Name(BOLD_FAMILY.into())
|
||||
}
|
||||
|
||||
pub fn bold(size: f32) -> FontId {
|
||||
FontId::new(size, bold_family())
|
||||
}
|
||||
|
||||
pub fn apply_dark(ctx: &egui::Context) {
|
||||
ctx.set_theme(egui::Theme::Dark);
|
||||
ctx.style_mut_of(egui::Theme::Dark, |style| {
|
||||
@@ -76,3 +124,32 @@ pub fn apply_black_window_frame(frame: &eframe::Frame) {
|
||||
pub fn apply_dark_window_frame(ctx: &egui::Context) {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::SetTheme(egui::SystemTheme::Dark));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn hack_is_used_for_all_text() {
|
||||
let ctx = egui::Context::default();
|
||||
install_fonts(&ctx);
|
||||
let _ = ctx.run(Default::default(), |_| {});
|
||||
ctx.fonts(|f| {
|
||||
// Hack is monospaced; egui's default proportional font is not.
|
||||
for font in [
|
||||
FontId::proportional(14.0),
|
||||
FontId::monospace(14.0),
|
||||
bold(14.0),
|
||||
] {
|
||||
assert_eq!(
|
||||
f.glyph_width(&font, 'i'),
|
||||
f.glyph_width(&font, 'W'),
|
||||
"{font:?}"
|
||||
);
|
||||
}
|
||||
// Emoji fallbacks for the tree icons are still available.
|
||||
assert!(f.has_glyph(&FontId::proportional(14.0), '📦'));
|
||||
assert!(f.has_glyph(&bold(14.0), '📦'));
|
||||
});
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use eframe::egui::{self, Color32, FontId, Key, ScrollArea, Sense, Shape, Stroke, pos2, vec2};
|
||||
use eframe::egui::{self, Color32, Key, ScrollArea, Sense, Shape, Stroke, pos2, vec2};
|
||||
|
||||
use crate::package::{NodeId, NodeKind, Package};
|
||||
|
||||
@@ -173,7 +173,7 @@ fn paint_row(
|
||||
let (label, label_font) = if is_root {
|
||||
(
|
||||
node.label.to_uppercase(),
|
||||
FontId::proportional(body.size - 1.0),
|
||||
super::theme::bold(body.size - 1.0),
|
||||
)
|
||||
} else {
|
||||
(node.label.clone(), body.clone())
|
||||
@@ -220,10 +220,6 @@ fn paint_row(
|
||||
painter.galley(pos, g, text_color);
|
||||
}
|
||||
let pos = pos2(text_x, center_y - label_galley.size().y / 2.0);
|
||||
if is_root {
|
||||
// Faux bold: egui's default font has no bold face.
|
||||
painter.galley(pos + vec2(0.5, 0.0), label_galley.clone(), text_color);
|
||||
}
|
||||
painter.galley(pos, label_galley, text_color);
|
||||
response
|
||||
}
|
||||
@@ -240,7 +236,7 @@ pub fn show(
|
||||
ui.label(
|
||||
egui::RichText::new("PACKAGE")
|
||||
.small()
|
||||
.strong()
|
||||
.family(super::theme::bold_family())
|
||||
.color(ui.visuals().weak_text_color()),
|
||||
);
|
||||
ui.add_space(2.0);
|
||||
|
||||
Reference in new issue
Block a user